N = int(input())
a_list = [None] * N
for i in range(N):
    a_list[i] = int(input())

#remove duplicate
sorted_a = sorted(list(set(a_list)), reverse = True)

result = []
for a in a_list:
    if a == sorted_a[0]:
        if len(sorted_a) >= 2:
            result.append(sorted_a[1])
        else:
            result.append(a)
    else:
        result.append(sorted_a[0])

for r in result:
    print(r)
