import sys
import numpy as np
input = sys.stdin.readline


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

    for j in range(N):
        if j != A.index(max(A)):
            print(np.max(A))
        else:
            ans = [x for i, x in enumerate(A) if i != j]
            print(np.max(ans))


if __name__ == "__main__":
    main()
