import copy

n = int(input())

lis = []
for _ in range(n):
    lis.append(int(input()))
    
m = max(lis)

for i in range(n):
    if lis[i] == m:
        tlis = copy.deepcopy(lis)
        tlis.remove(lis[i])
        print(max(tlis))
    else:
        print(m)