N = int(input())
A = [input() for _ in range(N)]

for i in range(0,N,2):
    if i == N-1:
        print(max(A[0:i]+A[i+1:len(A)]))
    else:
        print(max(A[0:i]+A[i+1:len(A)]))
        print(max(A[0:i+1]+A[i+2:len(A)]))