import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int tmp = Integer.parseInt(st.nextToken());
int max = tmp;
int min = tmp;
String result;
while(st.hasMoreTokens()){
tmp = Integer.parseInt(st.nextToken());
if(tmp> max){
max = tmp;
}else if(tmp<min){
min = tmp;
}
}
// result = sb.append(min).append(" ").append(max).toString() ;
System.out.print(min + " " + max);
}
}