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