N = int(input())
numbers = []
for i in range(N):
    numbers.append(int(input()))
    
for n in numbers:
    aaa = max(numbers)
    if aaa == n:
        print(sorted(numbers)[-2])
    else:
        print(aaa)