n = int(input())
l = [int(input()) for _ in range(n)]

for i in range(n):
    if i == 0:
        print(max(l[i+1:]))
    elif i == n-1:
        print(max(max(l[:i]), l[-1]))
    elif i == n:
        print(max(l[:i]))
    else:
        print(max(max(l[:i]), max(l[i+1:])))