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

public class olympiad_sm_2n {
    class Problem {
        int start, time, cost;

        Problem(int s, int t, int c) {
            this.start = s;
            this.time = t;
            this.cost = c;
        }
    }

    Problem[] ps;

    void solve() throws IOException {
        int n = nextInt();
        ps = new Problem[n];
        for (int i = 0; i < n; i++) {
            ps[i] = new Problem(nextInt(), nextInt(), nextInt());
        }
        int max = 0;
        formask:
        for (int mask = 0; mask < 1 << n; mask++) {

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if ((mask & (1 << i)) > 0 && (mask & (1 << j)) > 0) {
                        if (ps[i].start + ps[i].time > ps[j].start && ps[j].start + ps[j].time > ps[i].start) {
                            continue formask;
                        }
                    }
                }
            }
            int cost = 0;
            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) > 0) {
                    cost += ps[i].cost;
                }
            }
            max = Math.max(max, cost);
        }
        out.println(max);
    }

    StringTokenizer st;
    BufferedReader br;
    PrintWriter out;

    void run() throws IOException {
        br = new BufferedReader(new FileReader("olympiad.in"));
        out = new PrintWriter("olympiad.out");
        solve();
        out.close();
    }

    int nextInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        new olympiad_sm_2n().run();
    }
}
