N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
    A.insert(i,stor)
    print(ans)
    ans = A[0]