N = int(input())
s = [int(input()) for j in range(N)]
for i in range(0,N-1):
    if max(s) != s[i]:
        print(max(s))
    else:
        t = s[:i]
        u = s[i+1:]
        print(max(max(t, u, key=max)))