import copy
n = int(input())
a = []
for s in range(n):
    a.append(int(input()))
for t in range(n):
  if a[t] == max(a):
    b = copy.copy(a)
    b[t:t+1] = []
    print(max(b))
  else:
    print(max(a))