n=int(input())
a=[int(input()) for _ in range(n)]
aa=sorted(a[:])
for i in range(n):
    k=a[i]
    t=-1
    while True:
        if abs(t) > n:
            print(aa[0])
            break
        elif aa[t] != k:
            print(aa[t])
            break
        else: t -= 1