N = int(input())
A = [None for _ in range(N)]
for i in range(N):
  A[i] = int(input())
B = [[] for _ in range(N)]
for i in range(N):
  B[i] = [b for b in A if b != A[i]]
MAX = [None for _ in range(N)]
for i in range(N):
  MAX[i] = max(B[i])
for i in range(N):
  print(MAX[i])