n = int(input())
v = [int(input()) for i in range(n)]

v_max = max(v)
for i in range(n):
    if v[i] == max:
        v_i = v.pop(i)
        print(max(v))
        v.insert(i, v_i)
    else:
        print(v_max)