n = int(input())
a_l = [ int(input()) for _ in range(n)]

for i in range(n):
    if i == 0:
        l = 0
    else:
        l = max(a_l[:i])

    if i == n-1:
        r = 0
    else:
        r = max(a_l[i+1:])
    print(max([l,r]))