#include <bits/stdc++.h>
using namespace std;
struct ring {
  int B;
  int A;
  long long H;
} r;
bool cmp(ring a, ring b) {
  if (a.B == b.B)
    return a.A > b.A;
  else
    return a.B > b.B;
}
vector<struct ring> v;
stack<struct ring> tower;
int N;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> r.A >> r.B >> r.H;
    v.push_back(r);
  }
  sort(v.begin(), v.end(), cmp);
  long long mx = 0, cur = 0;
  for (int i = 0; i < N; i++) {
    while (!tower.empty() && v[i].B <= tower.top().A) {
      cur -= tower.top().H;
      tower.pop();
    }
    cur += v[i].H;
    tower.push(v[i]);
    mx = max(mx, cur);
  }
  cout << mx << endl;
  return 0;
}
