#include <bits/stdc++.h>
using namespace std;
long long int sp[100005][20];
int ar[2 * 100005], po[20];
long long int que(int a, int b) {
  int x = b - a + 1, y;
  y = ar[x], x -= po[y];
  return max(sp[a][y], sp[a + x][y]);
}
void up(int j, long long int a, int n) {
  int k, x, y;
  x = n - j, y = ar[x], sp[j][0] = a;
  for (k = 1; k <= y; k++)
    sp[j][k] = max(sp[j][k - 1], sp[j + po[k - 1]][k - 1]);
  return;
}
int main() {
  int n, i, a, b, h, k, l, m;
  scanf("%d", &n);
  vector<pair<pair<int, int>, int> > v(n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a), scanf("%d", &b), scanf("%d", &h);
    v[i].first.first = b, v[i].first.second = a, v[i].second = h;
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  vector<int> A(n), B(n), H(n);
  for (i = 0; i < n; i++)
    B[i] = v[i].first.first, A[i] = v[i].first.second, H[i] = v[i].second;
  vector<long long int> dp(n);
  ar[1] = 0, k = 1, po[0] = 1;
  while (k < n) {
    for (i = k + 1; i < 2 * k; i++) ar[i] = ar[k];
    ar[2 * k] = 1 + ar[k], k *= 2;
  }
  for (i = 1; i < 20; i++) po[i] = 2 * po[i - 1];
  for (i = n - 1; i >= 0; i--) {
    l = i, h = n - 1;
    while (l < h) {
      m = (l + h + 1) / 2;
      if (B[m] > A[i])
        l = m;
      else
        h = m - 1;
    }
    dp[i] = H[i];
    if (l > i) dp[i] += que(i + 1, l);
    up(i, dp[i], n);
  }
  long long int ans = 0;
  for (i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
}
