#include <stdio.h>
#include <algorithm>

using std::max;

struct meda {
	long id;
	long cena;
};

meda prodavnice[2000];
long mede[20000];

int main(int argc, char *argv[])
{
	for (size_t i=0; i<2000; i++) prodavnice[i].cena=0;
	FILE *fin = fopen("mede.in", "r");
	long n;
	fscanf(fin, "%d\n", &n);
	for (size_t j=0; j<n; j++) mede[j]=false;
	
	for (long loop_n=0; loop_n<n; loop_n++) {
		long ai, bi, ci;
		fscanf(fin, "%d %d %d\n", &ai, &bi, &ci);
		mede[loop_n]=ci;
		for (long loop_i=ai-1; loop_i<bi; loop_i++) {
			if (prodavnice[loop_i].cena<ci) {
				prodavnice[loop_i].cena=ci;
				prodavnice[loop_i].id=loop_n;
			}
		}
	}
	fclose(fin);

	for (long loop_z=0; loop_z<2000; loop_z++) {
		if (prodavnice[loop_z].cena) {
			mede[prodavnice[loop_z].id]=0;
		}
	}

	long sol=0;	
	for (long loop_m=0; loop_m<n; loop_m++) {
		sol += mede[loop_m];
	}
	
	FILE *fout = fopen("mede.out", "w");
	fprintf(fout, "%d\n", sol);
	fclose(fout);
}
