#include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > v[100005];
int main() {
  int n, a, b, c, attop, i, in, out, h;
  long long at[100005], rsp;
  scanf("%d", &n);
  rsp = 0;
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    v[i] = make_pair(b, make_pair(a, c));
  }
  sort(v, v + n);
  stack<pair<int, int> > pilha;
  for (i = n - 1; i >= 0; i--) {
    in = v[i].second.first;
    out = v[i].first;
    h = v[i].second.second;
    while (1) {
      if (pilha.empty()) break;
      attop = pilha.top().first;
      if (out > attop) break;
      pilha.pop();
    }
    if (pilha.empty())
      at[i] = h;
    else
      at[i] = at[pilha.top().second] + h;
    rsp = max(rsp, at[i]);
    pilha.push(make_pair(in, i));
  }
  printf("%lld\n", rsp);
}
