#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test = 1;
  while (test--) {
    long long n;
    cin >> n;
    vector<pair<pair<long long, long long>, long long> > a;
    for (long long i = 0; i < (long long)n; ++i) {
      long long x, y, z;
      cin >> x >> y >> z;
      a.push_back({{y, x}, z});
    }
    sort(a.begin(), a.end(),
         greater<pair<pair<long long, long long>, long long> >());
    stack<pair<pair<long long, long long>, long long> > stck;
    stck.push(a[0]);
    long long maxi = 0, curr = a[0].second;
    maxi = curr;
    long long i = 1;
    while (i < n) {
      if (stck.empty()) {
        stck.push(a[i]);
        curr += a[i].second;
        maxi = max(maxi, curr);
        ++i;
        continue;
      }
      auto elem = stck.top();
      if (a[i].first.first > elem.first.second) {
        stck.push(a[i]);
        curr += a[i].second;
        maxi = max(maxi, curr);
        ++i;
      } else {
        curr -= elem.second;
        stck.pop();
      }
    }
    cout << maxi;
  }
  return 0;
}
