N = int(input())

A = [0] * N
for i in range(N):
    a = int(input())
    A[i] = a

ans = 0
for i in range(N):
    tmp = A[:]
    tmp.sort(reverse=True)
    
    if tmp[0] == A[i]:
      print(tmp[1])
    else:
      print(tmp[0])   