#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct cc {
  int x, y, z;
  bool operator<(const cc &t) const {
    if (y != t.y)
      return y > t.y;
    else
      return x > t.x;
  }
} a[N];
struct xx {
  int w, id;
} q[N];
long long dp[N];
int main() {
  int n, m, i, j, k, ans, num, sum;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
  }
  sort(a + 1, a + n + 1);
  long long maxx = dp[1] = a[1].z;
  q[1] = {a[1].x, 1};
  int l = 1, r = 1;
  for (i = 2; i <= n; i++) {
    while (l <= r && q[r].w >= a[i].y) r--;
    dp[i] = dp[q[r].id] + a[i].z;
    q[++r] = {a[i].x, i};
    maxx = max(maxx, dp[i]);
  }
  printf("%lld\n", maxx);
  return 0;
}
