#include<iostream>
using namespace std;

int main(void)
{
	int n;
	while(cin >> n)
	{
		int MAX_Val = -0x3f3f3f3f;
		int MIN_Val = 0x3f3f3f3f;
		int temp;
		for(int i = 0;i < n;i++)
		{
			cin >> temp;
			if(temp > MAX_Val) MAX_Val = temp;
			if(temp < MIN_Val) MIN_Val = temp;
		}
		cout << MAX_Val << " " << MIN_Val<<endl;
	}
	
	
	
	return 0;
}