#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const int MAXN = 1e5 + 7;
struct RING {
  int inner, outer, height;
  RING() {}
  bool operator<(const RING &rhs) const {
    if (outer == rhs.outer) {
      if (inner == rhs.inner) return height > rhs.height;
      return inner > rhs.inner;
    }
    return outer > rhs.outer;
  }
} ring[MAXN];
int n;
map<int, int_fast64_t, greater<int> > msk;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d %d %d", &ring[i].inner, &ring[i].outer, &ring[i].height);
  sort(ring + 1, ring + 1 + n);
  msk.insert(make_pair(0, 0ll));
  for (int i = 1; i <= n; i++) {
    auto p = msk.upper_bound(ring[i].outer);
    int_fast64_t nextheight = p->second + ring[i].height;
    auto pp = msk.lower_bound(ring[i].inner);
    if (pp->second >= nextheight) continue;
    while (true) {
      auto ptr = msk.upper_bound(ring[i].inner);
      if (ptr == msk.begin()) break;
      advance(ptr, -1);
      if (ptr->second <= nextheight)
        msk.erase(ptr);
      else
        break;
    }
    msk.insert(make_pair(ring[i].inner, nextheight));
  }
  int_fast64_t ans = 0;
  for (auto p : msk) ans = max(ans, p.second);
  cout << ans << endl;
  return 0;
}
