n=int(input())
x=[]
for i in range(n):
  x.append(int(input()))
cnt = [0] * 50
for i in range(n):
  for j in range(n):
    if i is not j and cnt[i] < x[j]:
      cnt[i]=x[j]
  cnt[i]=str(cnt[i])+"\n"
print(cnt)