n = int(input())
list = []
for i in range(n) :
    list.append(int(input()))
for i in range(n) :
    sorted_list = sorted(list, reverse=True)
    idx = sorted_list.index(list[i])
    sorted_list.pop(idx)
    print(sorted_list[0])
