import copy
n = int(input())
a = list(map(int,[input() for i in range(n)]))
a_sorted =copy.copy(a)
a_sorted.sort()
if len(set(a))!=1:
  sec_big=list(set(a))[-2]
else:
  sec_big=list(set(a))[-1]

for num in a:
  if num == max(a):
    print(sec_big)
  else:
    print(max(a))