n = int(input())

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

#print(ls)

for i in li:
    j = 0
    while(j < n):
        #print("{}, {}.format(i,j))
        if(i != ls[j]):
            print(ls[j])
            break
        if (j == n-1):
            print(i)
        j+=1
    #print(max(p1,p2))