#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010, INF = 0x3f3f3f3f;
int n, st[N];
int main(){
scanf("%d", &n);
int min = INF, max = -INF;
int x;
while (cin >> x){// 通过判断是否还能输入
if (x > max) max = x;
if (x < min) min = x;
st[x] ++;
}
int lose, doub;
for (int i = min; i <= max; i ++){
if (st[i] == 0) lose = i;
if (st[i] > 1) doub = i;
}
cout << lose << " " << doub << endl;
return 0;
}