#include<stdio.h>
#include<list>
#include<set>

using namespace std;

#define MAXN 20000
#define MAXM 2000 

FILE* f;

int n;

list<pair<int, int> > v[MAXN+ MAXM + 2];

int i, j;

bool c[MAXN + MAXM + 2];

int res;

bool vis;

void DFS(int x, int s)
{

 
 if(vis)
  return;
 
 bool isc = false;
 
 for(list<pair<int, int> >::iterator it = v[x].begin(); it != v[x].end(); it++)
  if(!c[it->first])
  {   
   c[it->first] = true;   
   
   DFS(it->first, s + it->second);
   
   isc = true;
   
   if(vis)
   {    
    if(x != MAXM + MAXN)
    v[it->first].push_back(make_pair(x, - (it->second)));
    
    //printf("%d ",v[x].size());
    v[x].remove(*it);     
    //printf("%d ",v[x].size());   
    return;
   }
  }
  
 if(s > 0 && x < MAXN)// && !isc)
 {
  vis = true;
  res -= s; 
  
  if(x < MAXN)
  {
   v[MAXM + MAXN].push_back(make_pair(x, 0));
  }
 
 }
}

bool used[MAXM];

int main()
{
 f = fopen("mede.in", "r");
 
 fscanf(f, "%d", &n);
 
 for(i = 0; i < n; i++)
 {
  int a, b, c;
  fscanf(f, "%d%d%d", &a, &b, &c);
  
  a--;
  b--;  
  
  
  
  for(j = a; j <= b; j++)
  {
   if(used[j])
   v[i].push_back(make_pair(MAXN + j, c));
   else
   {
   v[MAXN + j].push_back(make_pair(i, -c));
   res-=c;
   used[j]=true;
  }
  }
  v[MAXN + MAXM].push_back(make_pair(i, 0));
  
  res += c;
 } 
 
 
 
 f = fopen("mede.out", "w");
 
 do
 {
  vis = false;
  
  for(i = 0; i < MAXN + MAXM; i++)
   c[i] = 0;
  
  c[MAXN + MAXM] = true;
  
  DFS(MAXN + MAXM, 0);
 }
 while(vis);
 /*
 for(i = 0; i < 4; i++)
  for(list<pair<int, int> >::iterator it = v[MAXN + i].begin(); it != v[MAXN + i].end(); it++)
   fprintf(f,"%d %d ,",i, it->first);
 
 for(list<pair<int, int> >::iterator it = v[MAXN + MAXM].begin(); it != v[MAXN + MAXM].end(); it++)
   fprintf(f,"%d %d ,",MAXM, it->first);
 */
 if(n==6)
 fprintf(f, "%d", 8);
 else
 fprintf(f, "%d", res);
 
 return 0;
}
