n = int(eval(input()))

a = []

for i in range(n):

    a.append(int(eval(input())))

a_max = max(a)

ind_M = a.index(a_max)

tmpl = a

tmpl.pop(ind_M)

for i in range(n):

    if i != ind_M:

        print(a_max)

    else:

        print((max(tmpl)))
def main():

    n = int(eval(input()))

    a = []

    for i in range(n):

        a.append(int(eval(input())))

    a_max = max(a)

    ind_M = a.index(a_max)

    tmpl = a

    tmpl.pop(ind_M)

    for i in range(n):

        if i != ind_M:

            print(a_max)

        else:

            print((max(tmpl)))





if __name__ == "__main__":

    main()

n = int(eval(input()))
a = []
for i in range(n):
    a.append(int(eval(input())))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print((max(tmpl)))

def main():
    n = int(eval(input()))
    a = []
    for i in range(n):
        a.append(int(eval(input())))
    a_max = max(a)
    ind_M = a.index(a_max)
    tmpl = a
    tmpl.pop(ind_M)
    for i in range(n):
        if i != ind_M:
            print(a_max)
        else:
            print((max(tmpl)))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -a = [] -for i in range(n): -    a.append(int(eval(input()))) -a_max = max(a) -ind_M = a.index(a_max) -tmpl = a -tmpl.pop(ind_M) -for i in range(n): -    if i != ind_M: -        print(a_max) -    else: -        print((max(tmpl))) +def main(): +    n = int(eval(input())) +    a = [] +    for i in range(n): +        a.append(int(eval(input()))) +    a_max = max(a) +    ind_M = a.index(a_max) +    tmpl = a +    tmpl.pop(ind_M) +    for i in range(n): +        if i != ind_M: +            print(a_max) +        else: +            print((max(tmpl))) + + +if __name__ == "__main__": +    main()