import copy
from sys import stdin
n=int(input())
A=[int(stdin.readline().rstrip()) for _ in range(n)]
m=max(A)
for j in range(0,n):
    B=copy.copy(A)
    s=A[j]
    A.pop(j)
    print(m)
    A = copy.copy(B)