#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, a, b, c, d, op, mij, ls, ld, ul, timp, k, l, r, ok, rasp, maxi,
    mini;
set<pair<int, long long int> > myset;
set<pair<int, long long int> >::iterator it, it2;
vector<pair<pair<int, int>, long long int> > v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> b >> a >> c;
    v.push_back(make_pair(make_pair(-a, -b), c));
  }
  myset.insert(make_pair(0, 0));
  sort(v.begin(), v.end());
  long long int prs = 1ll << 59;
  long long int a;
  for (i = 0; i < n; i++) {
    it = myset.upper_bound(make_pair(-v[i].first.first - 1, prs));
    if (it == myset.end()) {
      b++;
    }
    it--;
    a = it->second + v[i].second;
    it = myset.insert(make_pair(-v[i].first.second, a)).first;
    it--;
    if (it->second >= a) {
      it++;
      myset.erase(it);
      continue;
    }
    it++;
    it++;
    while (it != myset.end() && it->second <= a) {
      it2 = it;
      it++;
      myset.erase(it2);
    }
  }
  cout << myset.rbegin()->second;
  return 0;
}
