import copy

N=int(input())
L=[]
tmp=[]
for _ in range(N):
  L.append(int(input()))

h=max(L)

for i in range(N):
  if L[i]!=h:
    print(h)
  else:
    tmp=copy.deepcopy(L)
    del tmp[i]
    print(max(tmp))