import copy
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

for i in range(N):
  if max(A) != A[i]:
    print(max(A))
  else:
    AA = copy.deepcopy(A)
    AA.remove(max(A))
    print(max(AA))