#include <stdio.h>
int main(void)
{
int a[100001];
int i, n, temp, temp2;
int min, max;
int first = 1;
char ch;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
do
{
scanf("%d", &temp);
if (first)
{
min = max = temp;
first = 0;
}
else
{
if (temp < min)
min = temp;
if (temp > max)
max = temp;
}
a[temp]++;
ch = getchar();
} while (ch == ' ');
}
for (i = min; i < max; i++)
{
if (a[i] == 2)
temp = i;
if (a[i] == 0)
temp2 = i;
}
printf("%d %d\n", temp2, temp);
return 0;
}