# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [0 for _ in range(N)]
for i in range(N):
    a[i] = (i,int(input()))
a = sorted(a, key=lambda x: -x[1])

for i in range(N):
    for j in range(N):
        if a[i][0] == j:
            continue
        print(a[j][1])
        break
