n = int(input())
num = []
for i in range(n):
    a = int(input())
    num.append(a)

max_n = max(num)

for i in range(n):
    b = num[i]
    if b == max_n:
        num_c = num
        num_c[i] = 0
        print(max(num_c))
    else:
        print(max_n)