import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

enum int INF = 1 << 28;

alias Node = Tuple!(int, "value", int, "index");
bool comp(Node a, Node b) {
	if (a.value != b.value) {
		return a.value < b.value;
	}
	return a.index < b.index;
}

void main() {
	int n = readln.chomp.to!int;
	auto a = readln.chomp.split.map!(to!int).array;
	Node[] arr = new Node[](n);
	foreach (int i, v; a) {
		arr[i] = Node(v, i);
	}
	std.algorithm.sort!comp(arr);
	debug arr.writeln;
	Node atom = arr[$ - 1];
	auto sorted = arr.assumeSorted!comp;
	int half = atom.value / 2;
	auto left = sorted.lowerBound(Node(half + 1, INF));
	int best = int.max;
	int ans = -1;
	if (left.length) {
		int v = half - left.back.value;
		if (v < best) {
			best = v;
			ans = left.back.value;
		}
	}
	auto right = sorted.upperBound(Node(half - 1, -INF));
	if (right.length) {
		int v = right.front.value - half;
		if (v < best) {
			best = v;
			ans = right.front.value;
		}
	}
	writeln(atom.value, " ", ans);
}

