#include <bits/stdc++.h>
using namespace std;
const int N = 100 ;
int a[N] ;
int main() {
int n ;
cin>>n ;
for(int i = 0 ; i < n ; i++)
cin>>a[i] ;
sort(a, a + n) ;
cout<<a[n-1]<<' '<<a[n-2]<<'\n' ; /// a[n] for maximum element, and a[n-2] for the second maximum element
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gMTAwIDsKaW50IGFbTl0gOwppbnQgbWFpbigpIHsKICAgIGludCBuIDsKICAgIGNpbj4+biA7CiAgICBmb3IoaW50IGkgPSAwIDsgaSA8IG4gOyBpKyspCiAgICAgICAgY2luPj5hW2ldIDsKICAgIHNvcnQoYSwgYSArIG4pIDsKICAgIGNvdXQ8PGFbbi0xXTw8JyAnPDxhW24tMl08PCdcbicgOyAgIC8vLyBhW25dIGZvciBtYXhpbXVtIGVsZW1lbnQsIGFuZCBhW24tMl0gZm9yIHRoZSBzZWNvbmQgbWF4aW11bSBlbGVtZW50CiAgICByZXR1cm4gMDsKfQ==