n = int(eval(input()))

a = [int(eval(input())) for _ in range(n)]

b = a.copy()

b = sorted(b, reverse=True)

for i in a:

    if i == b[0]:

        print((b[1]))

    else:

        print((b[0]))

def main():

    import sys

    import collections

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    a = [int(input().rstrip('\n')) for _ in range(n)]

    b = sorted(a, reverse=True)

    for i in a:

        if i == b[0]:

            print((b[1]))

        else:

            print((b[0]))

            

            

if __name__ == '__main__':

    main()

n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
b = a.copy()
b = sorted(b, reverse=True)
for i in a:
    if i == b[0]:
        print((b[1]))
    else:
        print((b[0]))

def main():
    import sys
    import collections

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    a = [int(input().rstrip("\n")) for _ in range(n)]
    b = sorted(a, reverse=True)
    for i in a:
        if i == b[0]:
            print((b[1]))
        else:
            print((b[0]))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -a = [int(eval(input())) for _ in range(n)] -b = a.copy() -b = sorted(b, reverse=True) -for i in a: -    if i == b[0]: -        print((b[1])) -    else: -        print((b[0])) +def main(): +    import sys +    import collections + +    input = sys.stdin.readline +    n = int(input().rstrip("\n")) +    a = [int(input().rstrip("\n")) for _ in range(n)] +    b = sorted(a, reverse=True) +    for i in a: +        if i == b[0]: +            print((b[1])) +        else: +            print((b[0])) + + +if __name__ == "__main__": +    main()