n = int(input())
a = list(map(int, [input() for i in range(n)]))

sum = max(a)
for i in range(n):
    if a[i] == max(a):
        b = a[:]
        b.remove(a[i])
        print(max(b))
    else:
        print(sum)