N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
  A[i] = int(input())
  
A_temp = A[0]
A[0] = 0
print(max(A))
A[0]= A_temp

for i in range(1, N):
  B[i] = max(B[i-1],A[i])
  print(B[i])
    
