a = []
n = int(input())
for i in range(n):
    a.append(int(input()))
for i in range(n):
    if i == 0 : print(max(a[1:]))
    elif i == n - 1 : print(max(a[:i]))
    else:
        maxa = max(a[:i])
        maxb = max(a[i + 1:])
        print(max(maxa, maxb))

    
