#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 1;
long long s[3 * N];
set<int> sa;
struct tower {
  int a, b, h;
} t[N];
map<int, int> mp;
bool cmp(const tower& l, const tower& r) {
  if (l.b != r.b) return l.b > r.b;
  return l.a > r.a;
}
long long query(int root, int lo, int hi, int u, int v) {
  if (hi < lo || lo > v || hi < u) return 0;
  if (u <= lo && hi <= v) return s[root];
  int mid = ((lo + hi) >> 1), l = (root << 1), r = l + 1;
  return max(query(l, lo, mid, u, v), query(r, mid + 1, hi, u, v));
}
void update(int root, int lo, int hi, int u, int v, long long val) {
  if (hi < lo || lo > v || hi < u) return;
  if (u <= lo && hi <= v) {
    s[root] = max(s[root], val);
    return;
  }
  int mid = ((lo + hi) >> 1), l = (root << 1), r = l + 1;
  update(l, lo, mid, u, v, val);
  update(r, mid + 1, hi, u, v, val);
  s[root] = max(s[l], s[r]);
}
int main() {
  int n, i, j = 1;
  long long ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d%d", &t[i].a, &t[i].b, &t[i].h);
    sa.insert(t[i].a);
  }
  for (int i : sa) {
    mp[i] = j++;
  }
  --j;
  sort(t + 1, t + n + 1, cmp);
  for (i = 1; i <= n; ++i) {
    int q;
    if (mp.lower_bound(t[i].b) == mp.end())
      q = j;
    else
      q = (int)mp.lower_bound(t[i].b)->second - 1;
    long long p = query(1, 1, j, 1, q) + t[i].h;
    update(1, 1, j, mp[t[i].a], mp[t[i].a], p);
    ans = max(ans, p);
  }
  printf("%lld\n", ans);
  return 0;
}
