#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
const int N=400,M=1010;
const int NN=400,MM=2010;
const int INF=2139062143;
int n,m,k,s,t;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
int last[NN],le;
void cl()
{
	memset(last,0,sizeof(last));
	le=1;
}
struct node{
	int u,v,cap,flow,cost,next;
}edge[MM<<1];
void add(int u,int v,int cap,int cost)
{
	edge[++le].u=u,edge[le].v=v,edge[le].cap=cap,edge[le].cost=cost,edge[le].flow=0,edge[le].next=last[u],last[u]=le;
	edge[++le].u=v,edge[le].v=u,edge[le].cap=0,edge[le].cost=-cost,edge[le].flow=0,edge[le].next=last[v],last[v]=le;
}
bool vis[NN];
int d[NN];
int p[NN];
queue<int> q;
bool spfa()
{
	memset(d,127,sizeof(d));
	q.push(s);
	vis[s]=1,d[s]=0,p[s]=0;
	while (!q.empty())
	{
		int u=q.front();
		q.pop();
		vis[u]=0;
		for (register int i=last[u];i;i=edge[i].next)
		{
			int v=edge[i].v;
			if (edge[i].cap>edge[i].flow&&d[v]>d[u]+edge[i].cost)
			{
				d[v]=d[u]+edge[i].cost;
				p[v]=i;
				if (!vis[v])
				{
					vis[v]=1;
					q.push(v);
				}
			}
		}
	}
	return d[t]!=INF;
}
int maxflow,mincost;
void MCMF()
{
	maxflow=0,mincost=0;
	while (spfa())
	{
		int f=INF,u=t;
		while (u!=s)
		f=min(f,edge[p[u]].cap-edge[p[u]].flow),u=edge[p[u]].u;
		mincost+=f*d[t];
		maxflow+=f;
		u=t;
		while (u!=s)
		edge[p[u]].flow+=f,edge[p[u]^1].flow-=f,u=edge[p[u]].u;
	}
}
int main()
{
	while (scanf("%d",&n)!=EOF&&n)
	{
		cl();
		int maxday=0;
		s=0;
		add(s,1,2,0);
		for (register int i=1;i<=n;++i)
		{
			int u=read(),v=read(),cost=read();
			maxday=max(maxday,max(u,v));
			add(u,v+1,1,-cost);
		}
		for (register int i=1;i<=maxday;++i)
		add(i,i+1,2,0);
		t=maxday+1;
		MCMF();
		printf("%d\n",-mincost);
	}
	return 0;
}