#include <bits/stdc++.h>
using namespace std;
struct ring {
  int inside, outside, height;
} rings[200000];
long long all, tot;
bool cmp(ring a, ring b) {
  if (a.outside != b.outside) return a.outside < b.outside;
  return a.inside < b.inside;
}
int main() {
  int n;
  while (cin >> n) {
    all = 0;
    tot = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d", &rings[i].inside, &rings[i].outside, &rings[i].height);
    }
    sort(rings, rings + n, cmp);
    stack<ring> keys;
    for (int i = n - 1; i >= 0; i--) {
      while (1) {
        if (keys.empty()) break;
        ring key = keys.top();
        if (key.outside >= rings[i].outside && key.inside < rings[i].outside)
          break;
        all -= key.height;
        keys.pop();
      }
      keys.push(rings[i]);
      all += rings[i].height;
      tot = max(tot, all);
    }
    cout << tot << endl;
  }
}
