#include "iostream"
#include "vector"
using namespace std;
int main()
{
int m, t;
vector<int> v;
cin >> m;
for (int i = 0; i < m; i++)
{
while (1)
{
scanf("%d", &t);
v.push_back(t);
if (getchar() != ' ')
break;
}
}
sort(v.begin(), v.end());
int a, b;
for (vector<int>::iterator it = v.begin(); it != v.end() - 1; it++)//迭代器便利一下,和数组一样
{
if (*it == *(it + 1))
a = *it;
else if (*it != *(it + 1) - 1)
b = *it + 1;
}
cout << b << ' ' << a << endl;
system("pause");
return 0;
}