n = int(input())
a = list(map(int, [input() for i in range(n)]))

maxa=max(a)

for i in range(n):
    if a[i]==maxa:
        list = a[:]
        list.pop(i)
        list.sort(reverse=True)
        print(list[0])
    else:
        print(maxa)