#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef int Weight;
struct Edge{
  int src, dst;
  Weight cap, cost;
  int rev;
  Edge(int src, int dst, Weight cap, Weight cost, int rev=-1):
    src(src), dst(dst), cap(cap), cost(cost), rev(rev) {}
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;

void add_edge(Graph& G, int src, int dst, Weight cap, Weight cost){
  G[src].push_back(Edge(src, dst, cap, cost, G[dst].size()));
  G[dst].push_back(Edge(dst, src, 0, -cost, G[src].size() - 1));
}

Weight min_cost_flow(Graph& G, int s, int t, Weight f){
  typedef pair<Weight, int> P;
  Weight res = 0;
  int V = G.size();
  vector<Weight> h(V, 0);
  vector<int> prevv(V);
  vector<int> preve(V);
  if(s == t) return 0;
  bool start = true;
  while(f > 0){
    vector<Weight> dist(V, INF);
    if(start){
      start = false;
      bool update = true;
      dist[s] = 0;
      while(update){
        update = false;
        REP(v, V){
          if(dist[v] == INF) continue;
          REP(i, G[v].size()){
            Edge& e = G[v][i];
            if(e.cap > 0 && dist[e.dst] > dist[v] + e.cost){
              dist[e.dst] = dist[v] + e.cost;
              prevv[e.dst] = v;
              preve[e.dst] = i;
              update = true;
            }
          }
        }
      }
    }else{
      priority_queue<P, vector<P>, greater<P> > que;
      dist[s] = 0;
      que.push(P(0, s));
      while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        REP(i, G[v].size()){
          Edge& e = G[v][i];
          if(e.cap > 0 && dist[e.dst] > dist[v] + e.cost + h[v] - h[e.dst]){
            dist[e.dst] = dist[v] + e.cost + h[v] - h[e.dst];
            prevv[e.dst] = v;
            preve[e.dst] = i;
            que.push(P(dist[e.dst], e.dst));
          }
        }
      }
    }
    if(dist[t] == INF) return -1;
    REP(v, V) h[v] += dist[v];

    Weight 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;
}

int main(){
  int N;
  while(cin>>N && N){
    Graph G(366);
    REP(i, N){
      int a, b, c;
      cin>>a>>b>>c;
      add_edge(G, a - 1, b, 1, -c);
    }
    REP(i, 365){
      add_edge(G, i, i + 1, 2, 0);
    }
    cout<<-min_cost_flow(G, 0, 365, 2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1320