// Arup Guha
// 12/27/2018
// Solution to 2018 Dec Bronze USACO Problem: The Bucket List

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Scanner;

public class blist {
	
	final public static int MAXTIME = 1000;
	
	public static void main(String[] args) throws Exception {
		
		Scanner stdin = new Scanner(new File("blist.in"));	
		
		int[] event = new int[MAXTIME+1];
		int n = stdin.nextInt();
		
		// Store info about each event.
		for (int i=0; i<n; i++) {
			int start = stdin.nextInt();
			int end = stdin.nextInt();
			int amt = stdin.nextInt();
			event[start] += amt;
			event[end] -= amt;
		}
		
		// Now, go in order, processing events, keeping track of max.
		int res = 0, cur = 0;
		for (int i=0; i<=MAXTIME; i++) {
			cur += event[i];
			res = Math.max(res,  cur);
		}

		// Print out the result.
		PrintWriter out = new PrintWriter(new FileWriter("blist.out"));
		out.println(res);
		out.close();		
		stdin.close();
	}
}
