#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

template <typename flow_t, typename cost_t>
struct PrimalDual {
  struct edge {
    int to;
    flow_t cap;
    cost_t cost;
    int rev;
    edge() {}
    edge(int to, flow_t cap, cost_t cost, int rev) : to(to), cap(cap), cost(cost), rev(rev) {}
  };
  const cost_t INF;
  vector<vector<edge>> G;
  vector<cost_t> h,dist;
  vector<int> prevv,preve;
  PrimalDual(int V) : INF(numeric_limits<cost_t>::max()), G(V) {}
  void add_edge(int from, int to, flow_t cap, cost_t cost) {
    G[from].emplace_back(to, cap, cost, G[to].size());
    G[to].emplace_back(from, 0, -cost, G[from].size()-1);
  }
  cost_t min_cost_flow(int s, int t, flow_t f) {
    int V = G.size();
    cost_t res = 0;
    using P = pair<cost_t,int>;
    priority_queue<P, vector<P>, greater<P>> que;
    h.assign(V,0);
    prevv.assign(V,-1);
    preve.assign(V,-1);
    while (f > 0) {
      dist.assign(V,INF);
      dist[s] = 0;
      que.emplace(0,s);
      while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
          edge &e = G[v][i];
          if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
            dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
            prevv[e.to] = v;
            preve[e.to] = i;
            que.emplace(dist[e.to], e.to);
          }
        }
      }
      if (dist[t] == INF) return -1;
      for (int v = 0; v < V; v++) h[v] += dist[v];
      flow_t d = f;
      for (int v = t; v != s; v = prevv[v]) {
        d = min(d, G[prevv[v]][preve[v]].cap);
      }
      f -= d;
      res += d * h[t];
      for (int v = t; v != s; v = prevv[v]) {
        edge &e = G[prevv[v]][preve[v]];
        e.cap -= d;
        G[v][e.rev].cap += d;
      }
    }
    return res;
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  while (cin >> N, N) {
    PrimalDual<int,int> P(400);
    for (int i = 1; i < 400; i++) {
      for (int j = i+1; j+1 < 400; j++) {
        P.add_edge(i,j,2,0);
      }
    }
    REP(i,N) {
      int s,t,w;
      cin >> s >> t >> w;
      P.add_edge(s,t+1,1,-w);
    }
    cout << -P.min_cost_flow(1,370,2) << endl;
  }

  return 0;
}


Measured memory_bytes: 9696