N = int(input())

A = []
for i in range(N):
    A.append(int(input()))

list_max = max(A)

import copy

for i in range(N):
    if A[i] != list_max:
        print(list_max)
    else:
        _tmp = copy.copy(A)
        _tmp.pop(i)
        print(max(_tmp))