#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, h;
  cin >> n;
  pair<int, pair<int, int> > arr[(int)1e5 + 5];
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> h;
    arr[i].first = b;
    arr[i].second.first = a;
    arr[i].second.second = h;
  }
  sort(arr, arr + n);
  stack<int> s;
  long long int ht = 0;
  long long int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s.empty()) {
      s.push(i);
      ht += arr[i].second.second;
    } else {
      if (arr[s.top()].second.first >= arr[i].first) {
        while (1) {
          if (!s.empty()) {
            if (arr[s.top()].second.first >= arr[i].first) {
              ht -= arr[s.top()].second.second;
              s.pop();
            } else {
              break;
            }
          } else {
            break;
          }
        }
        s.push(i);
        ht += arr[i].second.second;
      } else {
        s.push(i);
        ht += arr[i].second.second;
      }
    }
    ans = max(ans, ht);
  }
  cout << ans << "\n";
  return 0;
}
