import numpy as np
n = int(input())
a =  [int(input()) for i in range(n)]
b = set(a)
c = max(b)
for i in range(n):
  if a[i] != c:
    print(c)
  else:
    print(int(max(np.concatenate([a[:i], a[i+1:]]))))