#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e4 + 10;
int t, n, m, k, l, r, op, x, y;
int mi, mx;
const int inf = 0x3f3f3f3f;
void solve() {
while (cin >> n) {
mi = inf,mx = -inf;
for (int i = 1; i <= n; i++) {
cin >> x;
mi = min(mi,x);
mx = max(mx,x);
}
cout<<mx<<" "<<mi<<"\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}