#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1111;
const int MAXX = 400;

struct Application {
  int s, t, w;
  bool operator < (const Application &a) const {
    return s < a.s;
  }
};

int N;
Application ap[MAXN];
int dp[MAXX][MAXX];

int main() {
  while (cin >> N && N) {
    for (int i = 0; i < N; ++i) {
      cin >> ap[i].s >> ap[i].t >> ap[i].w;
    }
    sort(ap, ap+N);
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < N; ++i) {
      for (int j = MAXX-1; j >= 0; --j) {
        for (int k = MAXX-1; k >= 0; --k) {
          if (j <= ap[i].s) {
            dp[ap[i].t+1][k] = max(dp[ap[i].t+1][k], dp[j][k] + ap[i].w);
          }
          if (k <= ap[i].s) {
            dp[j][ap[i].t+1] = max(dp[j][ap[i].t+1], dp[j][k] + ap[i].w);
          }
        }
      }
    }
    cout << *max_element(dp[0], dp[MAXX]) << endl;
  }
  return 0;
}