n = int(input())

li = [int(input()) for i in range(n)]
ls = sorted(li, reverse = True)

#print(ls)

for i in li:
    for j in ls:
        #print("{}, {}".format(i,j))
        if(i != j):
            print(j)
            break
    #print(max(p1,p2))