import sys
from bisect import bisect_left

input=sys.stdin.readline

n=int(input())
a=[int(input()) for _ in range(n)]

A=sorted(a)
max_a=A[-1]

for i in range(n):
    if a[i]==max_a:
        idx=bisect_left(A,a[i])
        print(A[idx-1])
    else:
        print(max_a)
