#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
vector<pair<long long int, pair<long long int, long long int> > > v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int n, b, a, h;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> h;
    v.push_back(make_pair(b, make_pair(a, h)));
  }
  sort(v.rbegin(), v.rend());
  long long int tot = 0, ans = 0, sz = 0;
  vector<long long int> tmp;
  for (int i = 0; i < n; i++) {
    while (!tmp.empty()) {
      if (v[i].first > v[tmp[sz - 1]].second.first) break;
      tot -= v[tmp[sz - 1]].second.second;
      tmp.pop_back();
      sz--;
    }
    tot += v[i].second.second;
    if (ans < tot) ans = tot;
    tmp.push_back(i);
    sz++;
  }
  cout << ans << endl;
  return 0;
}
