#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
const int oo = 1e9 + 7;
int n;
pair<pair<int, int>, int> a[maxn];
pair<int, long long> s[maxn];
int sn;
void print() {
  for (int i = 1; i <= n; i++)
    cout << a[i].first.first << " " << a[i].first.second << " " << a[i].second
         << "\n";
}
int cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return (a.first.second > b.first.second ||
          a.first.second == b.first.second && a.first.first > b.first.first);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i].first.first >> a[i].first.second >> a[i].second;
  sort(a + 1, a + n + 1, cmp);
  long long tmp, res = 0;
  for (int i = 1; i <= n; i++) {
    while (s[sn].first >= a[i].first.second) sn--;
    tmp = s[sn].second + a[i].second;
    if (tmp > res) res = tmp;
    while (s[sn].first >= a[i].first.first) sn--;
    sn++;
    s[sn].first = a[i].first.first;
    s[sn].second = tmp;
  }
  cout << res << endl;
  return 0;
}
