#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int N = 365;
constexpr int INF = 1 << 30;

bool solve() {
    int m;
    std::cin >> m;
    if (m == 0) return false;

    std::vector<std::tuple<int, int, int>> ts(m);
    for (auto& t : ts) {
        int l, r, c;
        std::cin >> l >> r >> c;
        t = std::make_tuple(--l, r, c);
    }
    std::sort(ts.begin(), ts.end());

    auto dp = vec(N + 1, vec(N + 1, 0));

    for (auto t : ts) {
        int l, r, c;
        std::tie(l, r, c) = t;

        for (int i = N; i >= 0; --i) {
            dp[i][r] = std::max(dp[i][r], dp[i][l] + c);
            dp[r][i] = std::max(dp[r][i], dp[l][i] + c);
        }

        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j <= N; ++j) {
                if (i + 1 <= N) dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]);
                if (j + 1 <= N) dp[i][j + 1] = std::max(dp[i][j + 1], dp[i][j]);
            }
        }
    }

    std::cout << dp[N][N] << "\n";

    return true;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    while (solve()) {}

    return 0;
}

