#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++) /// O(n)
cin>>a[i] ;
sort(a, a + n) ; /// O(n log (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+biA7CiAgICBmb3IoaW50IGkgPSAwIDsgaSA8IG4gOyBpKyspIC8vLyBPKG4pCiAgICAgICAgY2luPj5hW2ldIDsKICAgIHNvcnQoYSwgYSArIG4pIDsgIC8vLyBPKG4gbG9nIChuKSkKICAgIGNvdXQ8PGFbbi0xXTw8JyAnPDxhW24tMl08PCdcbicgOyAgIC8vLyBhW25dIGZvciBtYXhpbXVtIGVsZW1lbnQsIGFuZCBhW24tMl0gZm9yIHRoZSBzZWNvbmQgbWF4aW11bSBlbGVtZW50CiAgICByZXR1cm4gMDsKfQ==