#include <iostream>
using namespace std;

int main() {
    int N;
    while (scanf("%d", &N) != EOF) { // 注意 while 处理多个 case
        int max,min;
        int num;
        for(int i = 0; i < N; i++){
            scanf("%d", &num);
            if(0 == i){
                max = num;
                min = num;
            }else{
                if(num > max){
                    max = num;
                }
                if(num < min){
                    min = num;
                }
            }
        }
        printf("%d %d\n", max, min);
    }
}
// 64 位输出请用 printf("%lld")