#include<bits/stdc++.h>
 
using namespace std;
 
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
 
 
template <typename T>
struct Point2D
{
	T x;
	T y;
 
	friend ostream& operator<<(ostream& os, const Point2D<T>& point);
};
 
ostream& operator<<(ostream& os, const Point2D<int>& point)
{
	os << "(" << point.x << ',' << point.y << ")";
	return os;
}
 
template<class T>
using StdAlloc = std::allocator<T>;
 
template <class T>
unsigned long long UniqueElementNum(const vector<T>& data)
{
	auto copy = data;
 
	sort(begin(copy), end(copy));
	copy.erase(unique(begin(copy), end(copy)), end(copy));
 
	return copy.size();
 
	//set<unsigned long long>(begin(copy), end(copy)).size();	
}
 
 
long long gcd(long long a, long long b)
{
	long long c;
 
	if (a < b) {
		a += b; b = a - b; a -= b;
	}
 
	while (b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
 
	return a;
}
 
 
bool IsPrime(ULL num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; 
 
	double sqrtNum = sqrt(num);
	for (ULL i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
 
			return false;
		}
	}
 
 
	return true;
}
 
 
void DecomposePrime(ULL n, vector<tuple<ULL, ULL>>& result)
{
	vector<ULL> primeList;
 
 
	ULL a = 2;
 
 
	while (n >= a * a) {
 
		if (n % a == 0) {
			primeList.emplace_back(a);
			n /= a;
		}
		else {
			a++;
		}
	}
 
	primeList.emplace_back(n);
 
 
 
	set<ULL> uniquePrimeList(begin(primeList), end(primeList));
	for (const auto& p : uniquePrimeList) {
		ULL primeNum = count(begin(primeList), end(primeList), p);
		result.emplace_back(make_tuple(p, primeNum));
	}
}
 
 
template <typename Type>
Type nCr(Type n, Type r) {
	Type ans = 1;
	for (Type i = n; i > n - r; --i) {
		ans = ans*i;
	}
	for (Type i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
 
 
template<class Num, class Container>
void InitContainer(Num num, Container& container) 
{
	container.resize(num);
	for (auto& d : container) {
		cin >> d;
	}
}
 
 
template<class Num, template<class T, class Allocator = StdAlloc<T>> class Container, class T2>
void InitContainer(Num num, Container<Point2D<T2>>& firstContainer)
{
	firstContainer.resize(num);
	for (auto& d : firstContainer) {
		cin >> d.x >> d.y;
	}
}
 
 
template<class Num, class First, class... Rest>
void InitContainer(Num num, First& first, Rest&... rest)
{
	InitContainer(num, first);
	InitContainer(num, rest...);
}
 
 
template <class Num, class... Container>
void InitNumAndContainer(Num& num, Container&... container)
{
	cin >> num;
	InitContainer(num, container...);
}
 
 
template <template<class T, class Allocator = StdAlloc<T>> class Container, class T>
void ShowContainer(const Container<T>& container)
{
	ostream_iterator<T> outItr(cout, "\n");
	copy(container.begin(), container.end(), outItr);
	cout << endl;
}
 
 
 
int main() 
{
	int N;
	cin >> N;
	
	vector<long long> AList;
	InitContainer(N, AList);
 
	sort(begin(AList), end(AList));
	
	long long n = AList.back();
	long long nearest = AList.front();
	//long long nearest = AList[N / 2 - 1];
	for (const auto& r : AList) {
		if (n == r) {
			continue;
		}
 
		if (abs( n / 2.0 - r ) <= abs(n / 2.0 - nearest)) {
			nearest = r;
		}
	}
 
	cout << n << " " << nearest << endl;
 
	return 0;
}

Measured memory_bytes: 1024