# include <iostream>

using namespace std;

const int MaxB = 2005;
const int MaxN = 20005;

struct Bear {
       int sta;
       int end;
       int cost;
       
       bool operator<( const Bear& other ) const {
            return end < other.end;
       }
};

int n;
Bear bears[MaxN];

int sum = 0;
int dp[2][MaxB];

int main() {
    freopen( "mede.in", "r", stdin );
    freopen( "mede.out", "w", stdout );
    
    scanf( "%d", &n );
    for ( int i = 0; i < n; i++ ) {
        scanf( "%d%d%d", &bears[i].sta, &bears[i].end, &bears[i].cost );
        sum += bears[i].cost;
    }
        
    sort( bears, bears + n );
    
    int r = 0;
    memset( dp, 0, sizeof( dp ) );
    for ( int i = 0; i < n; i++ ) {
        for ( int j = bears[i].sta; j <= bears[i].end; j++ ) {
            dp[i & 1][j] = max( dp[( i + 1 ) & 1][j], dp[( i + 1 ) & 1][j - 1] + bears[i].cost );
            r = max( r, dp[i & 1][j] );
        }
        for ( int j = 1; j < MaxB; j++ )
            dp[i & 1][j] = max( dp[i & 1][j], dp[i & 1][j - 1] );
    }
    
    printf( "%d\n", sum - r );
    
    return 0;
}
