#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+1e4;
ll n;
ll a[N];
signed main()
{
while(cin>>n)
{
for(ll i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
cout<<a[n]<<" "<<a[1]<<"\n";
}
}