# 入力
N = int(input())

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

num_max = max(num_list)
for i in range(N):
    if num_list[i] >= num_max:
        target = num_list[:i] + num_list[i+1:]
        print(max(target))
    else:
        print(num_max)