n = int(input())
array = []

for i in range(n):
    array.append(int(input()))

m = max(array)
c = array.count(m)

for e in array:
    sa = array[:]
    if e != m:
        print(m)
    else:
        if 1 < c:
            print(m)
        else:
            sa.remove(m)
            print(max(sa))
