import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int N = Integer.parseInt( br.readLine() );
String[] STR = br.readLine().split(" ");
List<Integer> list = new ArrayList<>();
for(String str : STR){
list.add( Integer.parseInt(str));
}
int min = list.get(0);
int max = list.get(0);
for(int i = 1; i<list.size();i++){
if(min>list.get(i)){
min = list.get(i);
}
if(max<list.get(i)){
max = list.get(i);
}
}
bw.write(min + " " + max);
bw.flush();
bw.close();
}
}