data = input().split()
N = int(data[0])
A = []
for i in range(N):
    inp = int(input())
    A.append(inp)

ans = 0
for i in range(N):
    rem = A[i]
    A[i] = 0
    if A[i] > ans and A[i] > rem:
        print(ans)
    else:
        Ao = sorted(A)
        ans = Ao[N-1]
        A[i] = rem
        print(ans)