import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N;
int min = 1000001;
int max = -1000001;
N = sc.nextInt();
int[] arr = new int[N];
for (int i=0; i<N; i++) {
arr[i] = sc.nextInt();
if (arr[i] < min )
min = arr[i];
if (arr[i] > max)
max = arr[i];
}
System.out.printf(min + " " + max);
sc.close();
}
}