while True: try: n = int(input()) a = list(map(int, input().split())) res = sorted(a) print("%d %d"%(res[-1], res[0])) except: break
while True: try: n = int(input()) a = list(map(int, input().split())) res = sorted(a) print("%d %d"%(res[-1], res[0])) except: break