#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    while(cin>>N)
    {
        vector<int> v;
        int data;
        while(N--)
        {
            cin>>data;
            v.push_back(data);
        }
        cout<<*max_element(v.begin(),v.end())<<" "<<*min_element(v.begin(),v.end())<<endl;
    }
}
// 64 位输出请用 printf("%lld")