#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;

struct P
{
  int s,e,cost;
  P(int s=0,int e=0,int cost=0):s(s),e(e),cost(cost){}
  bool operator < (const P& p)const
  {
    if(s!=p.s)return s < p.s;
    return e < p.e;
  } 
};

void printVP(vector<P> vec)
{
  cout << "printVP------" << endl;
  rep(i,vec.size())
    cout<< "(" << vec[i].s << "," << vec[i].e << "," << vec[i].cost << ") ";
  cout << endl;
}

void printVVI(VVI G)
{
  cout << "printVVI ------ "<< endl;
  rep(i,G.size())
    {
      rep(j,G[i].size())
	{
	  if(G[i][j] == 0)cout << "    0 ";
	  else cout << string(5-(log10(G[i][j])+1),' ') << G[i][j] << " "; 
	}
      cout << endl;
    }
  cout << endl;
}

int main()
{
  int N;
  while(cin >> N,N)
    {
      int MAX = 367;
      //dp[i][j] := １つめの部屋がi日めで2つ目の部屋がj日の時の最大利益
      VVI dp(MAX,VI(MAX,0));
      vector<P> requests(N);
      rep(i,N)
	cin >> requests[i].s >> requests[i].e >> requests[i].cost;
      sort(requests.begin(),requests.end());
      //printVP(requests);
  
      rep(k,N)
	{
	  VVI DP = dp;
	  REP(i,1,MAX)
	    {
	      REP(j,1,MAX)
		{
		  if(i == j && j == requests[k].e+1)
		    {
		      assert(requests[k].s-1 >= 0);
		      DP[i][j] = max(DP[i][j],
				     max(dp[requests[k].s][j]+requests[k].cost,
					 dp[i][requests[k].s]+requests[k].cost));
		    }
		  else if(j == requests[k].e+1)
		    {
		      assert(requests[k].s-1 >= 0);
		      DP[i][j] = max(DP[i][j],
				     dp[i][requests[k].s]+requests[k].cost);
		    }
		  else if(i == requests[k].e+1)
		    {
		      assert(requests[k].s-1 >= 0);
		      DP[i][j] = max(DP[i][j],
				     dp[requests[k].s][j]+requests[k].cost);
		    }
		  
		    DP[i][j] = max(DP[i][j],
				   max(DP[i-1][j],DP[i][j-1]));
		}
	    }
	  dp = DP;
	  //cout << "k = " << k << endl;
	  //printVVI(dp);
	}
      cout << dp[MAX-1][MAX-1] << endl;
    }
  return 0;
}