n = int(input())
al = list(int(input()) for _ in range(n))

for i in range(n):
    if i == 0:
        print(max(al[i:]))
    elif i == n-1:
        print(max(al[:i+1]))
    else:
        print(max(max(al[:i]), max(al[i+1:])))