#include <bits/stdc++.h>
using namespace std;
int que,chong;
int main(){
int n;
cin>>n;
vector<int> v;
for(int i=0;i<n;i++){
int x;
while(cin>>x) v.push_back(x);
scanf("\n");
}
sort(v.begin(),v.end());
for(int i=0;i<v.size()-1;i++){
if(v[i+1]-v[i]==2) que=v[i]+1;
if(v[i+1]-v[i]==0) chong=v[i];
}
cout<<que<<" "<<chong<<endl;
return 0;
}