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