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

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    int n = a.reduce!max;
    // n/2 に最も近い値を選ぶ
    int k = a.filter!(e => e != n).reduce!((a, b) => abs(a - n/2) <= abs(b - n/2) ? a : b);
    writeln(n, " ", k);
}

void main() {
    readint;
    auto a = readints;
    calc(a);
}
