#include<iostream>
#include<algorithm>
using namespace std;
const int N = 10010;
int num[N];
int main(){
int n;
while(cin>>n){
for(int i=0;i<n;i++) cin>>num[i];
sort(num,num+n);
cout<<num[n-1]<<" "<<num[0]<<endl;
}
}