#include <bits/stdc++.h>
using namespace std;
struct T {
  int l, r, h;
} a[100005];
int n;
long long f[100005] = {};
bool cmp(T t1, T t2) {
  if (t1.r == t2.r) return t1.l > t2.l;
  return t1.r > t2.r;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].l >> a[i].r >> a[i].h;
  sort(a + 1, a + n + 1, cmp);
  long long ans = 0;
  stack<int> stk;
  for (int i = 1; i <= n; i++) {
    while (!stk.empty() && a[stk.top()].l >= a[i].r) stk.pop();
    if (stk.empty())
      f[i] = a[i].h;
    else
      f[i] = f[stk.top()] + a[i].h;
    ans = max(ans, f[i]);
    stk.push(i);
  }
  cout << ans << endl;
  return 0;
}
