import copy
n = int(input())
string_list = [int(input()) for i in range(n)]

max_num = max(string_list)

for j in string_list:
    if j != max_num:
        print(max_num)
    else:
        templist = copy.deepcopy(string_list)
        templist.remove(j)
        print(max(templist))