import copy

N = int(input())
l = []
for i in range(N):
  l.append(int(input()))

mv = max(l)
for i in range(N):
  if l[i] < mv:
    print(mv)
  if l[i] == mv:
    a = copy.copy(l)
    del a[i]
    print(max(a))
