import numpy as np
N = int(input())
A = np.array([int(input()) for _ in range(N)])
tf_list = [True] * N
for i in range(N):
    if i != 0:
        tf_list[i-1] = True
    tf_list[i] = False
    print(np.max(A[tf_list]))
