n=int(input())
li=[int(input()) for _ in range(n)]

max_=0
for _ in range(n-1):
  res=li[0]
  del li[0]
  ans=max(li)
  if ans>max_:
    print(ans)
  else:
    print(max_)
  if res>max_:
    max_=res
    
print(max_)