#include <bits/stdc++.h>
using namespace std;
long long MOD = 100000000;
long long pw(long long a, long long b) {
  long long r = 1;
  while (b > 0) {
    if (b & 1) {
      r = (r * a) % MOD;
    }
    b = b >> 1;
    a = (a * a) % MOD;
  }
  return (r) % MOD;
}
struct node {
  int i, o, h;
};
long long BIT[211111] = {};
void update(int id, long long val) {
  for (; id <= 211111; id += (id & -id)) {
    BIT[id] = max(val, BIT[id]);
  }
}
long long query(int id) {
  long long mx = 0;
  for (; id > 0; id -= (id & -id)) {
    mx = max(mx, BIT[id]);
  }
  return mx;
}
bool cmp(struct node a, struct node b) {
  if (a.o == b.o) {
    if (a.i == b.i) {
      return a.h > b.h;
    } else {
      return a.i > b.i;
    }
  } else {
    return a.o > b.o;
  }
}
vector<int> all_radius;
int pos_in_all(int val) {
  return 1 + (lower_bound(all_radius.begin(), all_radius.end(), val) -
              all_radius.begin());
}
int main() {
  int n;
  vector<struct node> v;
  struct node tmp;
  int a, b, c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    tmp.i = a;
    tmp.o = b;
    tmp.h = c;
    v.push_back(tmp);
    all_radius.push_back(a);
    all_radius.push_back(b);
  }
  sort(v.begin(), v.end(), cmp);
  sort(all_radius.begin(), all_radius.end());
  long long mxh = 0;
  for (int i = 0; i < n; i++) {
    v[i].i = pos_in_all(v[i].i);
    v[i].o = pos_in_all(v[i].o);
  }
  long long qh;
  for (int i = 0; i < n; i++) {
    qh = query(v[i].o - 1);
    mxh = max(mxh, qh + v[i].h);
    update(v[i].i, qh + v[i].h);
  }
  cout << mxh;
  printf("\n");
  return 0;
}
