import numpy as np
import copy
  
N = int(input())  
A = np.zeros(N)

for i in range(N):
    A[i] = int(input())

B = copy.deepcopy(A)

for i in range(N):
    B = np.delete(A, i)
    print(int(np.max(B)))
    B = copy.deepcopy(A)