#include <bits/stdc++.h>
using namespace std;
int n, n1 = 1;
map<int, int> m;
struct node {
  int a, b, h;
} p[100005];
int ql, qr;
long long a[500005];
long long query(int k, int l, int r) {
  if (ql > r || qr < l) return 0;
  if (ql <= l && r <= qr)
    return a[k];
  else {
    int m = (l + r) / 2;
    return max(query(k << 1, l, m), query(k << 1 | 1, m + 1, r));
  }
}
void upd(int x, long long d) {
  x += n1 - 1;
  a[x] = max(a[x], d);
  while (x > 1) x >>= 1, a[x] = max(a[x << 1], a[x << 1 | 1]);
}
bool cmp(node a, node b) { return a.b > b.b; }
int main() {
  cin >> n;
  m.clear();
  n = 1;
  while (~scanf("%d%d%d", &p[n].a, &p[n].b, &p[n].h)) {
    int u = p[n].b;
    if (!m.count(u))
      m[u] = n++;
    else {
      p[m[u]].h += p[n].h;
      p[m[u]].a = min(p[m[u]].a, p[n].a);
    }
  }
  n--;
  m.clear();
  int q = 0;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    v.push_back(p[i].a);
    v.push_back(p[i].b);
  }
  sort(v.begin(), v.end());
  for (int i : v)
    if (!m.count(i)) m[i] = ++q;
  for (int i = 1; i <= n; i++) {
    p[i].a = m[p[i].a];
    p[i].b = m[p[i].b];
  }
  sort(p + 1, p + n + 1, cmp);
  while (n1 < m.size()) n1 <<= 1;
  for (int i = 1; i <= n; i++) {
    ql = 1;
    qr = p[i].b - 1;
    long long u = query(1, 1, n1) + p[i].h;
    upd(p[i].a, u);
  }
  cout << a[1] << "\n";
  return 0;
}
