import copy
def test(a_,n_):
    return abs(int(0.1/(n_-(a_+0.1))))

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
n_max = sum(x == a_max for x in a)
if n_max > 1:
    a_max_2 = a_max
    for _ in range(n):
        print(a_max)
else:
    #a_max_2=sorted(set(a))[-2]
    b = copy.copy(a)
    b.remove(a_max)
    a_max_2 = max(b)
    for i in a:
        x = test(i, a_max)
        print((1-x)*a_max + x*a_max_2)