#include <bits/stdc++.h>
using namespace std;
struct Ring {
  int a, b, h;
  bool operator<(const Ring &A) const {
    if (b != A.b) return b < A.b;
    return a < A.a;
  }
};
Ring a[100010];
int n, b[100010], nxt[100010];
priority_queue<int, vector<int>, greater<int> > q;
vector<int> v[100010];
long long f[100010], ans;
long long Dfs(int x) {
  if (x == n) return 0;
  if (f[x] != 0) return f[x];
  f[x] = a[x].h + Dfs(nxt[x]);
  return f[x];
}
int main() {
  memset(f, 0, sizeof(f));
  memset(nxt, 0x3f3f3f3f, sizeof(nxt));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d%d", &a[i].a, &a[i].b, &a[i].h);
  sort(a, a + n);
  for (int i = 0; i < n; i++) b[i] = a[i].b;
  for (int i = n - 1; i >= 0; i--) {
    int x = upper_bound(b, b + i, a[i].a) - b;
    if (x < i) v[x].push_back(i);
  }
  q.push(n);
  for (int i = 0; i < n; i++) {
    while (q.top() <= i) q.pop();
    for (int j = 0; j < v[i].size(); j++) q.push(v[i][j]);
    nxt[i] = q.top();
  }
  ans = 0;
  for (int i = 0; i < n; i++) {
    Dfs(i);
    ans = max(ans, f[i]);
  }
  printf("%I64d\n", ans);
  return 0;
}
