#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Elm {
  int l, r, w;
};
void solve(int n) {
  vector<Elm> v;
  for(int i=0;i<n;++i) {
    int l, r, w; cin >> l >> r >> w;
    r++;
    v.push_back({l, r, w});
  }
  sort(v.begin(), v.end(), [](Elm e1, Elm e2){return (e1.l == e2.l) ? e1.r < e2.r : e1.l < e2.l;});
  vvi dp(367, vi(367, 0));
  for(int i=0;i<n;++i) {
    int l = v[i].l, r = v[i].r, w = v[i].w;
    for(int j=366;j>=1;--j) {
      for(int k=366;k>=1;--k) {
        if(j <= l) {
          dp[r][k] = max(dp[r][k], dp[j][k] + w);
        }
        if(k <= l) {
          dp[j][r] = max(dp[j][r], dp[j][k] + w);
        }
      }
    }
  }
  int ans = 0;
  for(int i=1;i<367;++i) {
    for(int j=1;j<367;++j) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    solve(n);
  }
}

