import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.bigint;

BigInt combi(BigInt n, BigInt r) {
    if (r == 0) return BigInt(1);
    if (n/2 < r) return combi(n, n-r);
    return combi(n-1,r) + combi(n-1,r-1);
}

void main() {
    /*
    nCr = n!/(n-r)!/r!
    nC(r+1) = n!/(n-r-1)!/(r+1)!

    nC(r+1) / nCr = (n-r)!r! / { (n-r-1)!(r+1)!}
                  = (n-r) / (r+1) > 1 のときはrを増加

                    n-r > r+1
                    n > 2r + 1
                    r < (n-1)/2　のときはrを増やしても良い
                    */


    auto N = readln.chomp.to!int;
    auto a = readln.split.to!(int[]);

    auto n = a.maxElement;

    auto top = (n-1)*.5;

    auto lower = a.filter!(x => x != n).filter!(x => x <= top);
    auto upper = a.filter!(x => x != n).filter!(x => x > top);

    if (lower.empty) {
        writefln("%d %d", n, upper.minElement);
    } else if (upper.empty) {
        writefln("%d %d", n, lower.maxElement);
    } else {
        auto r1 = lower.maxElement;
        auto r2 = upper.minElement;

        if (combi(BigInt(n), BigInt(r1)) > combi(BigInt(n), BigInt(r2))) {
            writefln("%d %d", n, r1);
        } else {
            writefln("%d %d", n, r2);
        }
    }
}

