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

b = []

for i in range(n):
    tmp = a[i]
    del a[i]
    b.append(max(a))
    a.insert(i,tmp)

for i in range(len(b)):
    print(b[i])
