#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Application{
  int i, j, w;
  Application(int i, int j, int w):
    i(i), j(j), w(w) {}
};

bool operator<(const Application& a, const Application& b){
  return a.j != b.j ? a.j < b.j : a.i != b.i ? a.i < b.i : a.w < b.w;
}

int main(){
  int n;
  while(cin >> n, n){
    int s, e, w;
    vector<Application> V(n,Application(0,0,0));
    for(int i = 0; i < n; ++i){
      cin >> s >> e >> w;
      V[i] = Application(s,e,w);
    }
    sort(V.begin(), V.end());
    int y = 366;
    vector< vector<int> > DP(y,vector<int>(y,0));

    for(int i = 0; i < n; ++i){
      vector< vector<int> > DP_(y,vector<int>(y,0));
      int s = V[i].i, e = V[i].j, w = V[i].w;
      for(int j = 0; j < y; ++j){
        for(int k = 0; k < y; ++k){
          DP_[j][k] = max(DP[j][k], DP_[j][k]);
          if(j < s) DP_[e][k] = max(DP_[e][k], DP[j][k] + w);
          if(k < s) DP_[j][e] = max(DP_[j][e], DP[j][k] + w);
          if(j > 0) DP_[j][k] = max(DP_[j][k], DP_[j-1][k]);
          if(k > 0) DP_[j][k] = max(DP_[j][k], DP_[j][k-1]);
        }
      }
      DP = DP_;
      /*
      cout << "----------------------------------" << endl;
      for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 4; ++j){
          printf("%02d ", DP[i][j]);
        }cout << endl;
      }
      */
    }
    cout << DP[y-1][y-1] << endl;

      
  }
  return 0;
}

