#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 110, M = 100010;
int cnt[M];
int line;
int repeat, breakk;
int main(){
int MIN = 999999, MAX = 0, a;
cin >> line;
while(line--){
while(cin >> a){
cnt[a] ++;
MAX = max(MAX, a);
MIN = min(MIN, a);
}
}
for(int i = MIN; i <= MAX; i++){
if(cnt[i] == 2) repeat = i;
if(cnt[i] == 0) breakk = i;
}
cout << breakk << ' ' << repeat << endl;
return 0;
}