import copy

N = int(input())
li = [int(input()) for i in range(N)]

for index, i in enumerate(li):
  tmp = copy.copy(li)

  ans = max(tmp)

  if ans == tmp[index]:
    tmp.pop(index)
    print(max(tmp))
  else:
    print(ans)