#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, A;
  long long f = 0, s = 0, i;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> A;
    if (f < A)
      s = f, f = A;
    else
      s = max(s, A);
  }
  cout << f << endl;
  cout << s << endl;
}
