n = int(input())
l = []
for i in range(n):
  f = int(input())
  l.append(f)
#print(l)
a = max(l)

for j in range(n):
  p = l.copy()
  #print(p)
  if p[j] != a:
    print(a)
  else:
    p.remove(p[j])
    #print(p)
    print(max(p))