import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int n = scanner.nextInt();
int max=Integer.MIN_VALUE,min=Integer.MAX_VALUE;
for (int i = 0; i < n; i++) {
int anInt = scanner.nextInt();
if(anInt>max){
max=anInt;
}
if(anInt<min){
min=anInt;
}
}
System.out.println(max+" "+min);
}
}
}