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

ans = max(ls)
for i in range(len(ls)):
    ls2 = copy.copy(ls)
    del ls2[i]
    if ans in ls2:
        print(ans)
    else:
        ls2.sort()
        print(ls2[-1])
    