#include <bits/stdc++.h>
using namespace std;
struct ring {
  int a;
  int b;
  long long h;
};
bool compareByH(const ring& one, const ring& two) {
  if (one.b == two.b) {
    return one.a > two.a;
  }
  return one.b > two.b;
}
bool greaterPair(const pair<int, long long>& one,
                 const pair<int, long long>& two) {
  return one.first > two.first;
}
int main() {
  int n;
  cin >> n;
  vector<ring> rings(n);
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> rings[i].a >> rings[i].b >> rings[i].h;
  }
  sort((rings).begin(), (rings).end(), compareByH);
  map<int, long long> heights;
  heights[0] = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    ring& curRing = rings[i];
    auto it = heights.lower_bound(curRing.b);
    it--;
    if (it->first >= 0) {
      long long newHeight = it->second + curRing.h;
      auto aIt = heights.lower_bound(curRing.a);
      while (aIt != heights.end()) {
        auto next = aIt;
        next++;
        if (aIt->second < newHeight) {
          heights.erase(aIt);
        } else {
          break;
        }
        aIt = next;
      }
      auto f = heights.find(curRing.a);
      if (f == heights.end() || f->second < newHeight) {
        heights[curRing.a] = newHeight;
      }
    }
  }
  long long maxH = 0;
  for (auto(it) = (heights).begin(); (it) != (heights).end(); (it)++) {
    if (it->second > maxH) {
      maxH = it->second;
    }
  }
  cout << maxH << endl;
  return 0;
}
