#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;

/*typedef struct {
        int a,b,c;
        } meda;

istream& operator>>(istream& in, meda& a)
{
         in>>a.a>>a.b>>a.c;
         return in;
}*/

int mycmp(const void* a, const void* b)
{
    int ap = *(int*) a;
    int bp = *(int*) b;
    return ap-bp;
}

int main(int argc, char *argv[])
{
    //unos i inicijalizacija
   ifstream in("mede.in");
             if (!in) return -1;
    
    int n;
    int *a,*b,*c,*d;
    int m=0;    
    int min=0;

    in>>n;
    
    a = new int [n];
    b = new int [n];
    c = new int [n];
    d = new int [n];
    
    for (int i=0;i<n;i++)
        {    in>>a[i]>>b[i]>>c[i];
             if (b[i]>m) m=b[i];
             d[i]=0;
        }
    in.close();
    int op = 0; //broj otvorenih prodavnice
    int oi = 0; //broj otvorenih intervala
    int dm = 0; //broj dostupnih meda
    int ri = 1; //redni broj intervala
    
    for (int i=1; i<=m; i++)
        {
             
             for (int j=0; j<n; j++)
                 {
                      if (a[j]==i) {
                                    oi++;
                                    dm++;
                                    d[j]=ri;
                                    
                                   }
                      if (b[j]==i) oi--;
                 }
             if (dm!=0) 
             {op++;
              if (oi==0)
                   {
                    int x = dm-op;
                    if (x>0)
                       {
                         int* f = new int [dm];
                         int ind = 0;
                         for (int j = 0; j < n; j++)
                             {
                                  if (d[j]==ri) {
                                                 f[ind]=c[j];
                                                 ind++;
                                                }
                             }   
                         qsort(f,dm,sizeof(*f),mycmp);
                         for (int j = 0; j < x; j++)
                             min+=f[j];
                       }
                    ri++;
                    op=0;
                    dm=0;
                   }
              }
        }
    ofstream out("mede.out");
    out<<min;
    out.close();
    //system("PAUSE");
    return EXIT_SUCCESS;
}
