n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
for i in range(n):
  tmp = max(a)
  if tmp == a[i]:
    a[i] = -1
    print(max(a))
    a[i] = tmp
  else:
    print(tmp)



"""
for i in range(n):
  if i == 0:
    print(max(a[i+1:]))
    continue
  if i == n-1:
    print(max(a[0:n-1]))
    break
  ans = max(max(a[0:i]),max(a[i+1:n]))
  print(ans)
  """