#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 15;
const int inf = (long long)0x3f3f3f3f;
const int MOD = 998244353;
struct Node {
  int a, b, h;
  bool operator<(const Node& x) const { return b > x.b; }
};
pair<int, long long> que[N];
Node arr[N];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      int a, b, h;
      scanf("%d%d%d", &a, &b, &h);
      arr[i] = Node{a, b, h};
    }
    sort(arr + 1, arr + 1 + n);
    long long ans = 0;
    map<int, long long> mp;
    vector<int> vec;
    int l = 1;
    while (l <= n) {
      int r = l;
      while (r <= n && arr[l].b == arr[r].b) {
        r++;
      }
      r--;
      long long res = 0;
      for (int i = l; i <= r; i++) {
        res += arr[i].h;
      }
      int i = l;
      auto it = mp.lower_bound(arr[i].b);
      if (it != mp.begin()) {
        it--;
        res += it->second;
      }
      for (int i = l; i <= r; i++) {
        it = mp.lower_bound(arr[i].a);
        while (it != mp.end() && res >= it->second) {
          vec.emplace_back(it->first);
          it++;
        }
        for (int v : vec) {
          mp.erase(v);
        }
        vec.clear();
        if (!mp.count(arr[i].a)) {
          mp[arr[i].a] = res;
        }
      }
      ans = max(ans, res);
      l = r + 1;
    }
    printf("%lld\n", ans);
  }
}
