#include <bits/stdc++.h>
using namespace std;
typedef struct ring {
  int inr, our;
  long long hei;
  ring(int inr = 0, int our = 0, long long hei = 0ll)
      : inr(inr), our(our), hei(hei) {}
  friend bool operator<(ring a, ring b) { return a.hei < b.hei; }
} Ring;
bool cmp(Ring a, Ring b) {
  if (a.our != b.our)
    return a.our > b.our;
  else
    return a.inr > b.inr;
}
const int maxn = 100000 + 10;
int n;
Ring R[maxn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> R[i].inr >> R[i].our >> R[i].hei;
  }
  sort(R, R + n, cmp);
  priority_queue<Ring> Q;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    while (!Q.empty() && R[i].our <= Q.top().inr) {
      Q.pop();
    }
    if (Q.empty()) {
      ans = max(R[i].hei, ans);
      Q.push(R[i]);
    } else {
      R[i].hei += Q.top().hei;
      ans = max(R[i].hei, ans);
      Q.push(R[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
