N = int(input())
a = [ int(input()) for i in range(N) ]
ans = [1]*N
for i,x in enumerate(a):
  if i == N-1:
    ans[i]=max(a[:i])
  else:
    ans[i]=max(max(a[:i],a[i+1:]))
    
for i in range(N):
  print(ans[i])