
N=int(input())
A = []
for n in range(N):
    A.append(int(input()))

forward = [0 for n in range(N)]
forward[0] = A[0]
backward = [0 for n in range(N)]
backward[N-1] = A[N-1]
for n in range(1,N):
    forward[n] = max(forward[n-1], A[n])
for n in range(N-1)[::-1]:
    backward[n] = max(backward[n+1], A[n])

# print(forward)
# print(backward)

for n in range(N):
    # print("====")
    # print(forward[:n])
    # print(backward[n+1:])
    print(max(forward[:n]+backward[n+1:]))
