import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int n = readint();
    int[] a = readints();

    int m = a.reduce!max;
    int mid = m / 2;
    int md = 1145141919, r = 0;
    
    foreach (i; a) if (i != m) {
        int d = abs(mid - i);
        if (d < md) {
            md = d;
            r = i;
        }
    }

    writeln(m, " ", r);
}