#include <bits/stdc++.h>
using namespace std;
pair<long long, pair<long long, long long> > v[200005];
long long ans[200005], arr[200005];
stack<long long> st;
int main() {
  std::ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 0; i <= n - 1; i++) {
    long long a, b, h;
    cin >> a >> b >> h;
    v[i] = make_pair(b, make_pair(a, h));
  }
  sort(v, v + n);
  for (long long i = n - 1; i >= 0; i--) arr[i] = v[i].second.first;
  ans[n - 1] = v[n - 1].second.second;
  st.push(n - 1);
  for (long long i = n - 2; i >= 0; i--) {
    long long curb = v[i].first;
    while (!st.empty() && curb <= arr[st.top()]) st.pop();
    if (st.empty()) {
      st.push(i);
      ans[i] = v[i].second.second;
    } else {
      long long ind = st.top();
      ans[i] = ans[ind] + v[i].second.second;
      st.push(i);
    }
  }
  long long *pt = max_element(ans, ans + n);
  cout << *pt << endl;
  return 0;
}
