num=int(input()) num_list=list(map(int, input().split())) print(str(min(num_list))+" "+str(max(num_list)))