#include <stdio.h>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long

#define INF 987654321
#define MaxN 20010
#define MaxM 2010
#define MaxNode 10000

struct meda {
    int a,b,c,rb;

    meda() {}
    meda( int _a, int _b, int _c, int _rb ) { a = _a; b = _b; c = _c; rb = _rb; }

    bool operator < ( const meda& b ) const {
        return c > b.c;
    }
};

meda med[MaxN];

class ClassIntervalTree {

  public:

   pair< int, int > cvor[MaxNode];
   vector< int > c[MaxNode];

   void Init( int node, int left, int right )
   {
       c[node].clear();
       cvor[node] = mp( left, -1 );

       if ( left == right ) return;

       Init( 2*node, left, (left+right)/2 );
       Init( 2*node+1, (left+right)/2+1, right );

   }

   pair<int,int> Update( int node, int left, int right, int ileft, int iright, int p, bool Delete )
   {

       if ( iright < left || ileft > right ) return cvor[node];

       //printf("UPDATE %d %d %d %d %d | %d %d ! %d %d\n",node,left,right,ileft,iright,cvor[node].f,cvor[node].s,p,Delete);
       //system("pause");

       if ( cvor[node].s == INF ) return cvor[node];

       if ( left == ileft && right == iright ) {
            if ( p == INF ) {
                return cvor[node] = mp( INF, INF );
            }
            if ( Delete ) {
                if ( c[node].size() > 0 ) c[node].pop_back();
            }
            else {
                c[node].pb(p);
            }

            if ( left == right )
                if ( Delete ) {
                    if ( c[node].size() == 0 ) return cvor[node] = mp( left, -1 );
                    else                       return cvor[node] = mp( left, c[node][ c[node].size()-1 ] );
                }
                else          return cvor[node] = mp( left, p );

            pair<int,int> tmp1 = cvor[ 2*node ];
            pair<int,int> tmp2 = cvor[ 2*node+1 ];

            pair<int,int> ret;

            if ( tmp1.s == -1 && tmp2.s == -1 ) {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, -1 );
                else                       return cvor[node] = mp( left, c[node][ c[node].size()-1 ] );
            }
            if ( tmp1.s == -1 ) {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, tmp1.s );
                else {
                    if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, -1 );
                    else                       return cvor[node] = mp( tmp1.f, c[node][ c[node].size()-1 ] );
                }
            }
            if ( tmp2.s == -1 ) {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp2.f, tmp2.s );
                else {
                    if ( c[node].size() == 0 ) return cvor[node] = mp( tmp2.f, -1 );
                    else                       return cvor[node] = mp( tmp2.f, c[node][ c[node].size()-1 ] );
                }
            }

            if ( med[ tmp1.s ].c > med[ tmp2.s ].c ) {
                ret.f = tmp2.f;
                if ( c[node].size() == 0 ) ret.s = tmp2.s;
                else {
                    if ( med[tmp2.s].c > med[ c[node][ c[node].size()-1 ] ].c ) return cvor[node] = tmp2;
                    else                                             return cvor[node] = mp( tmp2.f, c[node][ c[node].size()-1 ] );
                }
            }
            else {
                ret.f = tmp1.f;
                if ( c[node].size() == 0 ) ret.s = tmp1.s;
                else {
                    if ( med[tmp1.s].c > med[ c[node][ c[node].size()-1 ] ].c ) return cvor[node] = tmp1;
                    else                                             return cvor[node] = mp( tmp1.f, c[node][ c[node].size()-1 ] );
                }
            }
            return cvor[node] = ret;
       }

       int pom = (right + left) / 2;
       if ( pom >= ileft && pom+1 <= iright ) {
            pair<int,int> tmp1 = Update( 2*node, left, pom, ileft, pom, p, Delete );
            pair<int,int> tmp2 = Update( 2*node+1, pom+1, right, pom+1, iright, p, Delete );

            pair<int,int> ret;

            if ( tmp1.s == -1 && tmp2.s == -1 ) {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, -1 );
                else                       return cvor[node] = mp( left, c[node][ c[node].size()-1 ] );
            }
            if ( tmp1.s == -1 ) {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, tmp1.s );
                else {
                    if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, -1 );
                    else                       return cvor[node] = mp( tmp1.f, c[node][ c[node].size()-1 ] );
                }
            }
            if ( tmp2.s == -1 ) {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp2.f, tmp2.s );
                else {
                    if ( c[node].size() == 0 ) return cvor[node] = mp( tmp2.f, -1 );
                    else                       return cvor[node] = mp( tmp2.f, c[node][ c[node].size()-1 ] );
                }
            }



            if ( tmp1.s > tmp2.s ) {
                ret.f = tmp2.f;
                if ( c[node].size()-1 == 0 ) ret.s = tmp2.s;
                else {
                    if ( med[tmp2.s].c > med[ c[node][ c[node].size()-1 ] ].c ) return cvor[node] = tmp2;
                    else                                             return cvor[node] = mp( tmp2.f, c[node][ c[node].size()-1 ] );
                }
            }
            else {
                ret.f = tmp1.f;
                if ( c[node].size()-1 == 0 ) ret.s = tmp1.s;
                else {
                    if ( med[tmp1.s].c > med[ c[node][ c[node].size()-1 ] ].c ) return cvor[node] = tmp1;
                    else                                             return cvor[node] = mp( tmp1.f, c[node][ c[node].size()-1 ] );
                }
            }
            return cvor[node] = ret;
       }


       pair<int,int> tmp1 = Update( 2*node, left, pom, ileft, iright, p, Delete );
       pair<int,int> tmp2 = Update( 2*node+1, pom+1, right, ileft, iright, p, Delete );


       //printf("UPDATE %d %d %d %d %d | %d %d | %d %d\n",node,left,right,ileft,iright,tmp1.f,tmp1.s,tmp2.f,tmp2.s);
       //system("pause");

       pair<int,int> ret;

       if ( tmp1.s == -1 && tmp2.s == -1 ) {
            if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, -1 );
            else                       return cvor[node] = mp( left, c[node][ c[node].size()-1 ] );
        }
        if ( tmp1.s == -1 ) {
            if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, tmp1.s );
            else {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp1.f, -1 );
                else                       return cvor[node] = mp( tmp1.f, c[node][ c[node].size()-1 ] );
            }
        }
        if ( tmp2.s == -1 ) {
            if ( c[node].size() == 0 ) return cvor[node] = mp( tmp2.f, tmp2.s );
            else {
                if ( c[node].size() == 0 ) return cvor[node] = mp( tmp2.f, -1 );
                else                       return cvor[node] = mp( tmp2.f, c[node][ c[node].size()-1 ] );
            }
        }

        if ( tmp1.s == INF && tmp2.s == INF ) return cvor[node] = tmp1;


        if ( tmp1.s > tmp2.s ) {
            ret.f = tmp2.f;
            if ( c[node].size() == 0 ) ret.s = tmp2.s;
            else {
                if ( med[tmp2.s].c > med[ c[node][ c[node].size()-1 ] ].c ) return cvor[node] = tmp2;
                else                                             return cvor[node] = mp( tmp2.f, c[node][ c[node].size()-1 ] );
            }
        }
        else {
            ret.f = tmp1.f;
            if ( c[node].size() == 0 ) ret.s = tmp1.s;
            else {
                if ( med[tmp1.s].c > med[ c[node][ c[node].size()-1 ] ].c ) return cvor[node] = tmp1;
                else                                             return cvor[node] = mp( tmp1.f, c[node][ c[node].size()-1 ] );
            }
        }

        return cvor[node] = ret;

   }

   pair<int,int> Query( int node, int left, int right, int ileft, int iright )
   {
       //printf("%d %d %d %d %d | %d %d\n",node,left,right,ileft,iright,cvor[node].f,cvor[node].s);
       //system("pause");

       if ( iright < left || ileft > right ) return mp(INF,INF);

       if  ( ileft <= left && right <= iright ) {
            return cvor[node];
       }

       int pom = (right + left) / 2;
       pair<int,int> tmp1 = Query( 2*node, left, pom, ileft, iright );
       pair<int,int> tmp2 = Query( 2*node+1, pom+1, right, ileft, iright );


       //printf("%d %d %d %d %d | %d %d | %d %d\n",node,left,right,ileft,iright,tmp1.f,tmp1.s,tmp2.f,tmp2.s);
       //system("pause");

       pair<int,int> ret;
        if ( tmp1.s > tmp2.s ) {
            return tmp2;
        }
        else {
            return tmp1;
        }

   }

};

int n,m;
pair<int,int> tr; // polje, koji
ll ret;

ClassIntervalTree interval;

int main()
{
    freopen("mede.in","r",stdin);
    freopen("mede.out","w",stdout);

    interval.Init(1,1,MaxM);

    scanf("%d",&n);
    int m = 0;
    for (int i = 0; i < n; i++) {
       scanf("%d%d%d",&med[i].a,&med[i].b,&med[i].c);
       med[i].rb = i;
    }

    sort( med, med+n );
    for (int i = n-1; i >= 0; i--) {
        interval.Update( 1, 1, MaxM, med[i].a, med[i].b, med[i].rb, false );
    }

    for (int i = 0; i < n; i++) {
        //printf("********** %d ************\n",i);

        interval.Update( 1, 1, MaxM, med[i].a, med[i].b, i, true );
        tr = interval.Query( 1, 1, MaxM, med[i].a, med[i].b );
        //printf("TR = %d %d\n",tr.f,tr.s);
        if ( tr.s == INF ) ret += med[i].c;
        else if ( tr.s == -1 ) {
            interval.Update( 1, 1, MaxM, tr.f, tr.f, INF, false );
        }
        else if ( med[ tr.s ].c > med[i].c ) ret += med[i].c;
        else {
            interval.Update( 1, 1, MaxM, tr.f, tr.f, INF, false );
        }
    }

    printf("%d\n",ret);

    fclose(stdin);
    fclose(stdout);

    return 0;


}
