n = int(input())
h = []

for i in range(n):
    h.append(int(input()))
    
h_sort = sorted(h, reverse=True)

for i in range(n):
    if h[i] == h_sort[0]:
        print(h[1])
    else:
        print(h[-1])