#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct S {
  int a, b, h;
} f[N];
int cmp(S x, S y) {
  if (x.b != y.b) return x.b > y.b;
  return x.a > y.a;
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) scanf("%d%d%d", &f[i].a, &f[i].b, &f[i].h);
    sort(f, f + n, cmp);
    long long cnt = f[0].h, ma = cnt;
    stack<S> q;
    q.push(f[0]);
    for (int i = 1; i < n; i++) {
      while (!q.empty() && f[i].b <= q.top().a) {
        cnt -= q.top().h;
        q.pop();
      }
      q.push(f[i]);
      cnt += f[i].h;
      ma = max(ma, cnt);
    }
    printf("%I64d\n", ma);
  }
  return 0;
}
