count = int(input())
nlist = []
for i in range(count):
    a = int(input())
    nlist.append(a)
mlist = tuple(nlist)
biggest = max(mlist)
nlist.remove(biggest)

for i in range(count):
    if mlist[i] == biggest:
        print(max(nlist))
    else:
        print(biggest)
