#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, k, h, mi, ans;
pair<pair<long long, long long>, long long> a[100010], b[100010];
vector<pair<pair<long long, long long>, long long> > v;
int main() {
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> a[i].first.second >> a[i].first.first >> a[i].second;
  sort(a, a + n);
  m = 0;
  h = a[0].second;
  mi = a[0].first.second;
  for (i = 1; i < n; i++)
    if (a[i].first.first == a[i - 1].first.first) {
      h += a[i].second;
      mi = min(mi, a[i].first.second);
    } else {
      b[m++] = make_pair((make_pair((mi), (a[i - 1].first.first))), (h));
      h = a[i].second;
      mi = a[i].first.second;
    }
  b[m++] = make_pair((make_pair((mi), (a[i - 1].first.first))), (h));
  ans = h = 0;
  for (i = m - 1; i >= 0; i--) {
    while (v.size() > 0 && v.back().first.first >= b[i].first.second) {
      h -= v.back().second;
      v.pop_back();
    }
    h += b[i].second;
    v.push_back(b[i]);
    ans = max(ans, h);
  }
  cout << ans << endl;
  return 0;
}
