n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    if i == 0:
        print(max(a[i+1:]))
    elif i == n - 1:
        print(max(a[:i]))
    else:
        x = max(a[:i])
        y = max(a[i+1:])
        print(max(x, y))