#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
const int N = 10000;
int a[N];
int main()
{
int n,t=0,k=0,q,p;
memset(a,0,sizeof(a));
scanf("%d",&n);
while(~scanf("%d",&a[t]))
t++;
sort(a,a+t);
for(int i=0;i<t;i++)
{
if(a[i]+1!=a[i+1]&&a[i]!=a[i+1])
{
k++;q=a[i]+1;
}
if(a[i]==a[i+1])
{
k++;p=a[i+1];
}
if(k==2)
break;
}
printf("%d %d",q,p);
return 0;
}