N = int(input())
A = []
# input
for i in range(N):
  A.append(int(input()))
  
max_A = max(A)
# output
for i in range(N):
  if A[i] < max_A:
    print(max_A)
  else:
    tmp = A.copy();
    tmp.remove(A[i]);
    print(max(tmp))