def main():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    max_A = max(A)
    argmax_A = [i for i, x in enumerate(A) if x == max(A)]
    if len(argmax_A) == 1:
        for n in range(N):
            if n in argmax_A:
                tmp = A.pop(n)
                print(max(A))
                A.insert(n, tmp)
            else:
                print(max_A)
    else:
        for n in range(N):
            print(max_A)
        
if __name__ == '__main__':
    main()
