#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 111;
int n;
int a[MAX], b[MAX], h[MAX], id[MAX];
long long t[4 * MAX];
long long dp[MAX];
bool cmp(int i, int j) { return b[i] < b[j] || (b[i] == b[j] && a[i] < a[j]); }
void update(int v, int l, int r, int pos, long long x) {
  if (pos < l || pos >= r) return;
  if (l == r - 1) {
    t[v] = x;
    return;
  }
  int mid = (l + r) / 2;
  update(2 * v + 1, l, mid, pos, x);
  update(2 * v + 2, mid, r, pos, x);
  t[v] = max(t[2 * v + 1], t[2 * v + 2]);
}
long long query(int v, int l, int r, int ql, int qr) {
  if (qr <= l || r <= ql) return 0;
  if (ql <= l && r <= qr) return t[v];
  int mid = (l + r) / 2;
  long long left = query(2 * v + 1, l, mid, ql, qr);
  long long right = query(2 * v + 2, mid, r, ql, qr);
  return max(left, right);
}
int bin1(int l, int r, int x) {
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (b[id[l]] <= x)
      l = mid;
    else
      r = mid;
  }
  if (b[id[l]] > x) return l;
  return l + 1;
}
int bin2(int l, int r, int x) {
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (b[id[l]] <= x)
      l = mid;
    else
      r = mid;
  }
  if (b[id[l]] <= x) return l;
  return l + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> h[i];
    id[i] = i;
  }
  sort(id, id + n, cmp);
  dp[0] = h[id[0]];
  update(0, 0, n, 0, h[id[0]]);
  for (int i = 1; i < n; ++i) {
    int l = bin1(0, i, a[id[i]]);
    int r = bin2(0, i, b[id[i]]);
    dp[i] = h[id[i]];
    if (l != i && r != i) dp[i] += query(0, 0, n, l, r + 1);
    update(0, 0, n, i, dp[i]);
  }
  long long mx = 0;
  for (int i = 0; i < n; ++i) mx = max(mx, dp[i]);
  cout << mx;
  return 0;
}
