#h = list(map(int, input().split()))
#r = int(input())
#n, d = map(int, input().split())

n = int(input())
a = []

for i in range(n):
    a.append(int(input()))

sa = sorted(a)
sa.reverse()

h = {}
for i in sa:
    h[i] = i
    for j in sa:
        if j != i:
            h[i] = j
            break
            
for x in sa:
    print(h[x])
