n=int(input())
a=[int(input()) for i in range(n)]
m=set(sorted(a,reverse=True))
M=m[0]
indexes=[j for j,x in enumerate(a) if x==M]
for k in range(n):
  if a[k]==M and len(indexes)==1:
    print(m[1])
  else:
    print(M)

