import copy
a = int(input())
a_list = []
for i in range(a):
    a_list.append(int(input()))
b_list = copy.copy(a_list)
for i in range(len(a_list)):
    b_list.pop(i)
    print(max(b_list))
    b_list = copy.copy(a_list)