#include <iostream>
using namespace std;

const int N = 10010;
int a[N];
int main() {
    int n;
    while (cin >> n) {
        int min = 1000001, max = -1000001;
        for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
            if (x > max) max = x;
            if (x < min) min = x;
        }
        cout << max << " " << min << endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")