# coding: utf-8

n = int(input())

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

max_a = max(A)

for i in range(n):
    if max_a == A[i]:
        max_a = max(A[0:i] + A[i+1:n])
        print(max_a)
    else:
        print(max_a)