from sys import stdin

n = int(stdin.readline().rstrip())
a = [int(stdin.readline().rstrip()) for _ in range(n)]

for i in range(n):
    if i == n - 1:
        ai = a[:i]
    else:
        ai = a[:i] + a[i+1:]
    print(max(ai))