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