A = int(input())
r = []
for i in range(A):
    r.append(int(input()))
max_r = max(r)
for i in range(A):
    if max_r == r[i]:
        r.pop(i)
        print(max(r))
        r.insert(i,max_r)
    else:
        print(max_r)