#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
int n, a , b , ma=0,mb=1000000001;
cin >> n ;
cin >> a;
for( n--; n ; --n ){
cin >> b;
if(abs(a-b) < abs(ma-mb))
ma=a , mb=b;
else
if(abs(a-b) == abs(ma-mb) && ma+mb > a+b)
ma=a , mb=b;
a = b;
}
cout << ma << " " << mb;
return 0;
}