#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n, x, Max = 0, v[100];
cin >> n;
for(int i=1; i<=n; i++) cin >> v[i];
sort(v + 1, v + n + 1); x = n;
while(v[n] == v[x]) x--;
cout << v[n] << ' ' << v[x] << '\n';
return 0;
}