n=int(input())
ls=[]
ls_sort=[]
for i in range(n):
    a=int(input())
    ls.append(a)
    ls_sort.append(a)
ls_sort.sort()

for s in ls:
    lst_num=len(ls_sort)-1
    if s==ls_sort[lst_num]:
        print(ls[lst_num])
    else:
        print(ls[lst_num-1])

