n=int(input())
A = []
for _ in range(n):
  x = int(input())
  A.append(x)
standard = max(A)
for i in range(n):
  if A[i] != standard:
    print(standard)
  else:
    temp = 0
    for t in range(n):
      if t != i:
        if A[t] >= temp:
          temp = A[t]
    print(temp)