#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(int x);
inline void writeWord(const char *s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) c = getChar();
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
const int M = 1e5 + 5;
int n;
pair<pair<int, int>, int> b[M];
vector<int> cop;
long long t[8 * M];
long long dp[M];
void update(int v, int vl, int vr, int l, int r, long long val) {
  if (l > vr || r < vl) return;
  if (l <= vl && vr <= r)
    t[v] = max(t[v], val);
  else {
    int vm = (vl + vr) / 2;
    update(v * 2 + 1, vl, vm, l, r, val);
    update(v * 2 + 2, vm + 1, vr, l, r, val);
    t[v] = max(t[v * 2 + 1], t[v * 2 + 2]);
  }
}
long long get(int v, int vl, int vr, int l, int r) {
  if (l > vr || r < vl) return 0;
  if (l <= vl && vr <= r) return t[v];
  int vm = (vl + vr) / 2;
  return max(get(v * 2 + 1, vl, vm, l, r), get(v * 2 + 2, vm + 1, vr, l, r));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &b[i].first.second, &b[i].first.first, &b[i].second);
    cop.push_back(b[i].first.first), cop.push_back(b[i].first.second);
  }
  sort(cop.begin(), cop.end());
  for (int i = 0; i < n; ++i) {
    b[i].first.first =
        lower_bound(cop.begin(), cop.end(), b[i].first.first) - cop.begin() + 1;
    b[i].first.second = lower_bound(cop.begin(), cop.end(), b[i].first.second) -
                        cop.begin() + 1;
  }
  sort(b, b + n);
  dp[n - 1] = b[n - 1].second;
  update(0, 0, 2 * M, b[n - 1].first.second, b[n - 1].first.second, dp[n - 1]);
  long long mx = dp[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    long long x = get(0, 0, 2 * M, 0, b[i].first.first - 1);
    dp[i] = x + b[i].second;
    mx = max(mx, dp[i]);
    update(0, 0, 2 * M, b[i].first.second, b[i].first.second, dp[i]);
  }
  cout << mx;
}
