#include <bits/stdc++.h>
using namespace std;

int n, res;
struct club {
    int a, b, c;
};

club x[5005];
int f[5005];

bool cmp(club g, club h) {
    if (g.b != h.b) return g.b < h.b;
    return g.a < h.a;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i].a >> x[i].b >> x[i].c;
    }

    sort(x + 1, x + n + 1, cmp);

    res = 0;
    for (int i = 1; i <= n; i++) {
        f[i] = x[i].c;
        for (int j = 1; j < i; j++) {
            if (x[j].b <= x[i].a) {
                f[i] = max(f[i], f[j] + x[i].c);
            }
        }
    }


    for (int i = 1; i <= n; i++) {
        res = max(res, f[i]);
    }

    cout << res;
    return 0;
}