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

class Edge{
public:
	int to,cap,cost,rev;
	Edge(int to,int cap,int cost,int rev){
		this->to=to; this->cap=cap; this->cost=cost; this->rev=rev;
	}
};

const int V=367,INF=1<<28;
vector<Edge> G[V];
int dist[V],prevv[V],preve[V];

int minCostFlow(int s,int t,int f) {
	int ret=0;
	while(f>0){
		fill(begin(dist), end(dist), INF);
		dist[s]=0;
		bool update=true;
		while(update){
			update=false;
			for(int v=0; v<V; ++v){
				if(dist[v]==INF)	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){
						dist[e.to]= dist[v]+e.cost;
						prevv[e.to]=v;
						preve[e.to]=i;
						update=true;
					}
				}
			}
		}
		if(dist[t]==INF)	return -1;
		int d=f;
		for(int v=t; v!=s; v=prevv[v])	d = min(d, G[prevv[v]][preve[v]].cap);
		f-=d;
		ret += d*dist[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 ret;
}

void addEdge(int from,int to,int cap,int cost){
	G[from].push_back(Edge(to, cap, cost, G[to].size()));
	G[to].push_back(Edge(from, 0, -cost, G[from].size()-1));
}

int solve(int N){
	fill(begin(G), end(G), vector<Edge>());
	fill(begin(dist), end(dist), INF);
	fill(begin(prevv), end(prevv), 0);
	fill(begin(preve), end(preve), 0);
	for(int i=1; i<V; ++i)	addEdge(i-1, i, 2, 0);
	int a,b,c;
	for(int i=0; i<N; ++i){
		cin>>a>>b>>c;
		addEdge(a, b+1, 1, -c);
	}
	int ret = minCostFlow(0, V-1, 2);
	return -ret;
}

int main(){
	int N;
	while(cin>>N, N)	cout<< solve(N) <<endl;
	return 0;
}