import copy
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))
max_s = max(s)
d = copy.copy(s)
for i in range(n):
    if max_s != s[i]:
        print(max_s)
    else:
        d = copy.copy(s)
        del d[i]
        print(max(d))