/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
static int index; //배열 인덱스 값
//배열 인덱스 찾기
public static void arrayIndex(int n) {
if(n > 0) index = n + 4000; //입력된 값이 양수라면
else if(n < 0) index = n * -1; //음수라면
else index = 0; //0이라면
}
{
// your code goes here
Scanner sc
= new Scanner
(System.
in); int n = sc.nextInt(); //수의 총 갯수
int sum = 0; //입력된 수들의 합
int big = 0; //최대 빈도 수
int[] arr = new int[n]; //수
int[] count = new int[8002]; //카운팅 정렬
for(int i = 0; i < n; i++) { //수 입력
arr[i] = sc.nextInt();
arrayIndex(arr[i]);
count[index]++;
big = big > count[index] ? big : count[index]; //최대 빈도수 확인
sum += arr[i];
}
int cnt = 0; //두 번째로 작은 값 확인용 변수
int num = 4001; //최빈값
for(int i = 0; i < n; i++) {
arrayIndex(arr[i]);
if(count[index] == big && num != arr[i]) { //최대 빈도수이면서 중복되지 않은 값이라면
num = arr[i];
cnt++;
}
else continue;
if(cnt == 2) break;
}
System.
out.
println(arr
[n
/ 2]); System.
out.
println(arr
[n
- 1] - arr
[0]); sc.close();
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXN0YXRpYyBpbnQgaW5kZXg7CQkvL+uwsOyXtCDsnbjrjbHsiqQg6rCSCgkKCS8v67Cw7Je0IOyduOuNseyKpCDssL7quLAKCXB1YmxpYyBzdGF0aWMgdm9pZCBhcnJheUluZGV4KGludCBuKSB7CgkJaWYobiA+IDApIGluZGV4ID0gbiArI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