#include <bits/stdc++.h>
inline int Rand() { return (rand() << 16) | rand(); }
using namespace std;
const int N = 1001, NN = 100001, SMALL = 105, ALPH = 28, BIG = 1000001;
int n;
pair<int, pair<int, int> > a[NN * 5];
long long t[BIG * 4], p[BIG * 4], ans, res;
map<int, int> num;
void compress() {
  vector<int> v;
  for (int i = int(1); i <= int(n); i++)
    v.push_back(a[i].second.first), v.push_back(a[i].first);
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int i = int(0); i <= int(((int)(v).size()) - 1); i++)
    if (i == 0 || v[i] != v[i - 1]) num[v[i]] = ++cnt;
  for (int i = int(1); i <= int(n); i++)
    a[i].first = num[a[i].first], a[i].second.first = num[a[i].second.first];
}
void upd(int v, int cl, int cr, int pos, long long x) {
  if (cr < pos || cl > pos) return;
  if (cl >= pos && cr <= pos) {
    t[v] = max(t[v], x);
    return;
  }
  int mid = (cl + cr) / 2;
  upd(v * 2, cl, mid, pos, x);
  upd(v * 2 + 1, mid + 1, cr, pos, x);
  t[v] = max(t[v * 2], t[v * 2 + 1]);
}
long long get(int v, int cl, int cr, int ql, int qr) {
  if (cr < ql || qr < cl) return 0;
  if (cl >= ql && cr <= qr) return t[v];
  int mid = (cl + cr) / 2;
  return max(get(v * 2, cl, mid, ql, qr), get(v * 2 + 1, mid + 1, cr, ql, qr));
}
bool cmp(pair<int, pair<int, int> > x, pair<int, pair<int, int> > y) {
  return x.first < y.first ||
         (x.first == y.first && x.second.first < y.second.first);
}
int main() {
  srand(time(NULL));
  scanf("%d", &n);
  for (int i = int(1); i <= int(n); i++)
    scanf("%d %d %d", &a[i].second.first, &a[i].first, &a[i].second.second);
  compress();
  sort(a + 1, a + 1 + n, cmp);
  for (int i = int(n); i >= int(1); i--)
    res = get(1, 1, n + n, 1, a[i].first - 1) + a[i].second.second,
    ans = max(ans, res), upd(1, 1, n + n, a[i].second.first, res);
  cout << ans;
  return 0;
}
