#include<iostream> #include<algorithm> #include<cstdio> using namespace std; const int Maxn=1000000; static int n,m; static int A[Maxn]; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&A[i]); sort(A+1,A+n+1); printf("%d %d\n",A[n],A[n-1]); return 0; }