N = int(input())
ary = []
for i in range(N):
    ary.append(int(input()))
maximum = max(ary)
tmp = 0
for i in range(N):
    if ary[i] == maximum:
        tmp = ary[i]
        ary[i] = 0
        print(max(ary))
        ary[i] = tmp
    else:
        print(maximum)