#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int m = 0;
    for (int i = 0; i < n; i++) m = max(m, a[i]);
    int h = 0;
    for (int i = 0; i < n; i++) if (min(h,m-h) < min(a[i],m-a[i])) h = a[i];
    cout << m << " " << h << endl;
    return 0;
}
