#include <bits/stdc++.h>
using namespace std;
const int N = 1e7;
int a[N];
bool st[N];
int main()
{
int T;
cin >> T;
int n = 1;
while(cin >> a[n]) n ++ ;
n -- ;
sort(a + 1, a + n + 1);
int x = 0, y = 0;
for(int i = 1; i <= n; i ++ )
{
if(!x && a[i + 1] != a[i] + 1 && a[i + 1] != a[i]) x = a[i + 1] - 1;
if(st[a[i]]) y = a[i];
st[a[i]] = 1;
}
cout << x << ' ' << y;
}