n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
for i in range(n):
    if i == 0:
        ans = a[1:]
    if i == n:
        ans = a.pop(n)
    ans = a[:i] + a[i+1:]
    print(max(ans))