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