#include <bits/stdc++.h>
using namespace std;
struct Ring {
  long long h;
  int a, b;
  Ring() {}
  Ring(int hf, int af, int bf) {
    h = hf;
    a = af;
    b = bf;
  }
};
bool compare(const Ring &R1, const Ring &R2) {
  if (R1.b != R2.b) return R1.b < R2.b;
  return R1.a < R2.a;
}
long long tree[400010];
void update(int n, int l, int r, int i, long long v) {
  if (l > r)
    return;
  else if (l == r) {
    tree[n] = v;
    return;
  }
  int m = (l + r) / 2;
  if (i <= m)
    update(2 * n, l, m, i, v);
  else
    update(2 * n + 1, m + 1, r, i, v);
  tree[n] = max(tree[2 * n], tree[2 * n + 1]);
}
long long query(int n, int l, int r, int tl, int tr) {
  if (l > r)
    return 0;
  else if (l == tl and r == tr)
    return tree[n];
  else {
    int tm = (tl + tr) / 2;
    long long lmax = query(2 * n, l, min(tm, r), tl, tm),
              rmax = query(2 * n + 1, max(tm + 1, l), r, tm + 1, tr);
    return max(lmax, rmax);
  }
}
int main() {
  for (int i = 0; i < 400010; i++) tree[i] = 0;
  int n;
  cin >> n;
  Ring R[n + 1];
  R[0] = Ring(0, 0, 0);
  long long result[n + 1];
  result[0] = 0;
  for (int i = 1; i <= n; i++) cin >> R[i].a >> R[i].b >> R[i].h;
  sort(R, R + n + 1, compare);
  for (int i = 1; i <= n; i++) {
    int start = 0, end = i, mid = 0;
    while (start < end) {
      mid = (start + end) / 2;
      if (R[i].a >= R[mid].b)
        start = mid + 1;
      else
        end = mid;
    }
    result[i] = R[i].h + query(1, start, i - 1, 1, n);
    update(1, 1, n, i, result[i]);
  }
  printf("%lld\n", query(1, 1, n, 1, n));
  return 0;
}
