a = int(input())
b = [int(input()) for _ in range(a)]
c = b.copy()
b = sorted(b, reverse=True)
for i in c:
    d = False
    for j in b:
        if i != j:
            print(j)
            d = not d
            break
    if not d:
        print(b[0])
