import sys
input = sys.stdin.readline
n = int(input())

s = [int(input()) for i in range(n)]

maxNum = max(s)

def func(n):
  if maxNum < n:
    return maxNum
  else:
    list = s[:]
    list.remove(n)
    return max(list)

for i in s:
  print(func(i))
#print(list(map(func,s)))
