import sys
input = sys.stdin.readline
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))

n=0
for i in range(N):
    n,lst[i] = lst[i],n
    print(max(lst))
    n,lst[i] = lst[i],n
