https://www.acmicpc.net/problem/10818
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
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 min =Integer.parseInt(st.nextToken());
int max = min;
for(int i=0 ; i<N-1;i++){
int x= Integer.parseInt(st.nextToken());
if(x < min){
min = x;
}else if(x > max){
max = x;
}
}
System.out.println(min + " " + max);
}
}