import numpy as np
import sys

input = sys.stdin.readline

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

    A = np.array(A)
    i = 0

    for a in A:
        print(max(np.delete(A, i)))
        i = i + 1

if __name__ == '__main__':
    main()