from sys import stdin


def main():
    N = int(stdin.readline())
    A = [int(input()) for _ in range(N)]

    for a in A:
        if max(A) == a:
            new_A = sorted(A)
            print(new_A[1])
        else:
            print(max(A))


if __name__ == "__main__":
    main()
