N=int(input())
left=[]
right=[]
for i in range(N):
  k,l,r=map(int,input().split())
  if l >= r:left.append((i,k,l,r,l-r))
  else:right.append((i,k,l,r,r-l))
left = sorted(left, key=lambda x:x[4])
left = sorted(left, key=lambda x:x[1], reverse=True)
right = sorted(right, key=lambda x:x[4])
right = sorted(right, key=lambda x:x[1], reverse=True)

sum_ = 0
left_cnt, right_cnt = 0,0
while 1:
  try:
    idx,k,l,r,_ = left.pop()
    if left_cnt<k:
      sum_ += l
      left_cnt += 1
    else:
      sum_ += r
      left_cnt += 1
  except:
    pass
  try:
    idx,k,l,r,_ = right.pop()
    if N-right_cnt>k:
      sum_ += r
      right_cnt += 1
    else:
      sum_ += l
      right_cnt += 1
  except:
    pass
  if left_cnt+right_cnt==N:break

print(sum_)