#include <cstdio>
#include <algorithm>
using std::sort;
using std::max;

int dp[400][400];
struct apply{
    int a, b, c;
}applys[10000];
bool comp(apply a, apply b){return a.a < b.a;}

int main(){
    int N;
    while(scanf("%d", &N) && N){
        for(int i=0 ; i<=366 ; i++)
            for(int j=0 ; j<=366 ; j++)
                dp[i][j] = 0;
        for(int i=0 ; i<N ; i++){
            scanf("%d %d %d", &applys[i].a, &applys[i].b, &applys[i].c);
        }
        sort(applys, applys+N, comp);
        int ptr = 0;
        for(int i=0;i<366;i++){
            while(ptr<N && applys[ptr].a==i){
                int k = applys[ptr].b+1;
                int c = applys[ptr].c;
                for(int j=366;j>=i;j--){
                    dp[k][j] = max(dp[k][j], dp[i][j]+c);
                    dp[j][k] = max(dp[j][k], dp[j][i]+c);
                }
                ptr++;
            }
            for(int j=i;j<=366;j++){
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
                dp[j][i+1] = max(dp[j][i+1], dp[j][i]);
            }
            dp[i+1][i+1] = max(dp[i+1][i+1], dp[i][i+1]);
        }
        printf("%d\n", dp[366][366]);
    }
    return 0;
}