import numpy as np
n= int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
    
b = np.array(a)
np.sort(b)[::-1]
ans = [0]*n

for i in range(n):
    if a[i] == b[0]:
        ans[i] = b[1]
    else:
        ans[i] = b[0]
        
for i in range(n):
  print(ans[i])