import copy

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))
    
for i in range(N):
    tmp_list = copy.copy(a_list)
    if len(tmp_list) > 2:
        tmp_list = list(sorted(set(tmp_list), key=tmp_list.index))
        tmp_list.pop(i)
        print(max(tmp_list))
    else:
        tmp_list.pop(i)
        print(max(tmp_list))     