#include <stdio.h>

int main() {
	int inputnum,num,max,min,i = 2;
	scanf("%d",&inputnum);
	scanf ("%d",&num);
	max = min = num;
	
	while(i <= inputnum) {
		scanf("%d",&num);
		if(num > max) {
			max = num;
		}
		if(num < min) {
			min = num;
		}
		
		i += 1;
	}
	
	printf("%d %d",max,min);
	
	return 0;
}