#include <algorithm>
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    
    while(cin>>n){
        int num;
        vector<int> vec;
        for(int i=0;i<n;i++){
            cin>>num;
            vec.push_back(num);
        }
       auto it1= max_element(vec.begin(),vec.end());
       auto it2= min_element(vec.begin(),vec.end());
       cout<<*it1<<" "<<*it2<<endl;
    }

}
// 64 位输出请用 printf("%lld")