#include <bits/stdc++.h>
using namespace std;
struct node {
  long long a, b, h;
} c[100005];
long long n;
struct Segment_Tree {
  long long mx[(100005) * 8], X, C, L, R;
  void modify(long long o, long long l, long long r) {
    if (l == r) {
      mx[o] = C;
      return;
    }
    long long mid = l + r >> 1;
    if (X <= mid)
      modify(o << 1, l, mid);
    else
      modify(o << 1 | 1, mid + 1, r);
    mx[o] = max(mx[o << 1], mx[o << 1 | 1]);
  }
  long long qmax(long long o, long long l, long long r) {
    if (L <= l && r <= R) return mx[o];
    long long mid = l + r >> 1;
    if (L > mid) return qmax(o << 1 | 1, mid + 1, r);
    if (R <= mid)
      return qmax(o << 1, l, mid);
    else
      return max(qmax(o << 1 | 1, mid + 1, r), qmax(o << 1, l, mid));
  }
} Tree;
bool cmp(node x, node y) { return x.b == y.b ? x.a > y.a : x.b > y.b; }
int main() {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; ++i)
    scanf("%I64d%I64d%I64d", &c[i].a, &c[i].b, &c[i].h);
  sort(c + 1, c + n + 1, cmp);
  Tree.X = n;
  Tree.C = c[n].h;
  Tree.modify(1, 1, n);
  for (long long i = n - 1; i >= 1; --i) {
    long long l, r, lans = 0, rans = n;
    l = i + 1;
    r = n;
    while (l < r) {
      long long mid = (l + r >> 1) + 1;
      if (c[i].a < c[mid].b)
        l = mid;
      else
        r = mid - 1;
    }
    if (c[l].b <= c[i].a) l--;
    lans = i + 1;
    rans = l;
    if (rans < lans) {
      Tree.X = i;
      Tree.C = c[i].h;
      Tree.modify(1, 1, n);
      continue;
    }
    Tree.L = lans;
    Tree.R = rans;
    Tree.X = i;
    Tree.C = Tree.qmax(1, 1, n) + c[i].h;
    Tree.modify(1, 1, n);
  }
  Tree.L = 1;
  Tree.R = n;
  printf("%I64d\n", Tree.qmax(1, 1, n));
}
