N = int(input())
A = []

def remove_one(num, A):
    
    B = []
    N = len(A)

    if (num == 0):
        B = A[1:]
    elif (num == N):
        B = A[:N-1]
    else:
        B = A[:i-1] + A[i+1:]
    
    return(B)


for i in range(N):
    A.append(int(input()))

for i in range(N):
    B = remove_one(i+1,A)
    print(max(B))