import heapq

list = []
n = int(input())
for i in range(n):
    list.append(int(input()))
maxsize = max(list)

for j in range(n):
    a = list[j]
    if a == maxsize:
        list2 = heapq.nlargest(2, list)
        print(list2[1])
    else:
        print(maxsize)