#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int main(){ int n,s[N]; while(cin >> n){ for(int i = 0;i < n;i ++)cin >> s[i]; sort(s,s + n); cout << s[n - 1] << " " << s[0] << endl; } return 0; }