import numpy as np

n = int(input())
a = np.zeros(n, dtype=np.int64)
for i in range(n):
    a[i] = int(input())
for i in range(n):
    max1 = 0
    max2 = 0
    if len(a[:i]) != 0:
        max1 = np.max(a[:i])
    if len(a[i+1:]) != 0:
        max2 = np.max(a[i+1:])
    print(max(max1, max2))
