N=int(input())
A=[int(input()) for i in range(N)]
A_sub = A.copy()
A_sub.sort(reverse=True)
#print(A)

for i in range(N):
    # print(A[i])
    A_sub2 = A_sub.copy()
    A_sub2.remove(A[i])
    print(A_sub2[0])
    
