#c
n = int(input())
a = [int(input()) for _ in range(n)]
import copy
ans = []
a_max = max(a)
for i in range(len(a)):
    if a[i]==a_max:
        tmp = copy.deepcopy(a)
        tmp.pop(i)
        print(max(tmp))
    else:
        print(a_max)