#include<iostream>
using namespace std;
typedef long long LL;
const int N =1000010;
int line;
LL cnt[N];
int n, m;
int main(){
cin>>line;
int Min=100001, Max=0, a;
for(int i=0;i<line;i++){
while(cin>>a){
cnt[a]++;
Min = min(Min, a);
Max = max(Max, a);
}
}
for(int i=Min;i<Max;i++){
if(cnt[i] == 0) m = i;
else if(cnt[i] == 2) n = i;
}
cout<<m<<" "<<n<<endl;
return 0;
}