import java.util.*;
import java.io.*;

public class olympiad_sp implements Runnable {
	public static void main(String[] args) {
		new Thread(new olympiad_sp()).start();
	}

	@Override
	public void run() {
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	private final String FNAME = "olympiad";
	
	class Task {
		int s, t, c;
		long ans;
		
		Task() {
			s = nextInt();
			t = nextInt();
			c = nextInt();
		}
	}
	
	class Event implements Comparable<Event> {
		int t, n, type;
		
		Event(int t, int n, int type) {
			this.t = t;
			this.n = n;
			this.type = type;
		}

		@Override
		public int compareTo(Event o) {
			if (t != o.t) {
				return t - o.t;
			}
			return type - o.type;
		}
	}

	void solve() {
		int n = nextInt();
		Task[] t = new Task[n];
		Event[] e = new Event[2 * n];
		for (int i = 0; i < n; i++) {
			t[i] = new Task();
			e[2 * i] = new Event(t[i].s, i, 1);
			e[2 * i + 1] = new Event(t[i].s + t[i].t, i, -1);
		}
		Arrays.sort(e);
		long best = 0;
		for (Event ee : e) {
			if (ee.type == 1) {
				t[ee.n].ans = best + t[ee.n].c;
			} else {
				best = Math.max(best, t[ee.n].ans);
			}
		}
		out.println(best);
	}
}