#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
const long long N = 1e5 + 5;
struct Node {
  long long In, Out, High;
} a[N];
long long n, S[8 * N], Dp[N];
vector<long long> vc;
map<long long, long long> mp;
void Input() {
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i].In >> a[i].Out >> a[i].High;
  }
}
void Minimize() {
  for (long long i = 1; i <= n; ++i) {
    vc.push_back(a[i].In);
    vc.push_back(a[i].Out);
  }
  sort(vc.begin(), vc.end());
  for (long long i = vc.size() - 1; i >= 0; --i) {
    mp[vc[i]] = i + 1;
  }
  for (long long i = 1; i <= n; ++i) {
    a[i].In = mp[a[i].In];
    a[i].Out = mp[a[i].Out];
  }
}
long long Query(long long Low, long long High, long long u, long long v,
                long long x) {
  if (High < u || Low > v) return 0;
  if (u <= Low && High <= v) return S[x];
  long long Mid = (Low + High) / 2;
  return max(Query(Low, Mid, u, v, 2 * x),
             Query(Mid + 1, High, u, v, 2 * x + 1));
}
void Update(long long Low, long long High, long long u, long long Val,
            long long x) {
  if (High < u || Low > u) return;
  if (Low == High) {
    S[x] = Val;
    return;
  }
  long long Mid = (Low + High) / 2;
  Update(Low, Mid, u, Val, 2 * x);
  Update(Mid + 1, High, u, Val, 2 * x + 1);
  S[x] = max(S[2 * x], S[2 * x + 1]);
}
bool Cmp(const Node &a, const Node &b) {
  if (a.Out != b.Out) return a.Out > b.Out;
  return a.In > b.In;
}
void Solve() {
  Minimize();
  sort(a + 1, a + 1 + n, Cmp);
  long long Res = 0;
  for (long long i = 1; i <= n; ++i) {
    long long Pos = Query(1, 2 * n, 1, a[i].Out - 1, 1);
    Dp[i] = Dp[Pos] + a[i].High;
    Update(1, 2 * n, a[i].In, i, 1);
    Res = max(Res, Dp[i]);
  }
  cout << Res;
}
int main() {
  if (fopen("trash.inp", "r"))
    freopen("trash.inp", "r", stdin), freopen("trash.out", "w", stdout);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Input();
  Solve();
}
