32 lines
842 B
Java
32 lines
842 B
Java
import java.util.*;
|
|
|
|
public class _2467 {
|
|
public static void main(String[] args) {
|
|
Scanner sc = new Scanner(System.in);
|
|
int N = Integer.parseInt(sc.nextLine());
|
|
int[] nums = Arrays.stream(sc.nextLine().split(" "))
|
|
.mapToInt(Integer::parseInt)
|
|
.toArray();
|
|
sc.close();
|
|
|
|
int pL = 0, pR = N-1;
|
|
int value = Math.abs(nums[pL] + nums[pR]);
|
|
int resA = nums[pL], resB = nums[pR];
|
|
|
|
while(pL < pR) {
|
|
int temp = nums[pL] + nums[pR];
|
|
|
|
if(Math.abs(temp) < value) {
|
|
value = Math.abs(temp);
|
|
resA = nums[pL];
|
|
resB = nums[pR];
|
|
}
|
|
|
|
if(temp < 0) pL++;
|
|
else pR--;
|
|
}
|
|
|
|
System.out.printf("%d %d\n",resA, resB);
|
|
}
|
|
}
|