import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class olympiad_sm {
    class Problem implements Comparable<Problem> {
        int start, time, cost, id;
        long ans;
        Problem prev;

        Problem(int s, int t, int c, int id) {
            assert  1<= s && s<= 1e9;
            assert  1<= t && t<= 1e9;
            assert  1<= c && c<= 1e9;
            this.start = s;
            this.time = t;
            this.cost = c;
            this.id = id;
        }

        int end() {
            return start + time;
        }

        @Override
        public int compareTo(Problem o) {
            return start - o.start;
        }

        @Override
        public String toString() {
            return "Problem{" +
                    "start=" + start +
                    ", time=" + time +
                    ", cost=" + cost +
                    ", ans=" + ans +
                    ", id=" + id +
                    '}';
        }
    }

    class Event implements Comparable<Event> {
        int type;
        int time;
        Problem p;

        Event(int type, int time, Problem p) {
            this.type = type;
            this.time = time;
            this.p = p;
        }

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

    Problem[] ps;
    Event[] es;

    void solve() throws IOException {
        int n = nextInt();
        assert 1 <= n && n <= 100000;
        ps = new Problem[n];
        es = new Event[2 * n];
        for (int i = 0; i < n; i++) {
            ps[i] = new Problem(nextInt(), nextInt(), nextInt(), i + 1);
            es[2 * i] = new Event(1, ps[i].start, ps[i]);
            es[2 * i + 1] = new Event(-1, ps[i].start + ps[i].time, ps[i]);
        }
        Arrays.sort(es);

        Problem max = null;
        for (int i = 0; i < es.length; i++) {
            if (es[i].type == -1) {
                if (max == null || max.ans < es[i].p.ans) {
                    max = es[i].p;
                }
            } else {
                es[i].p.prev = max;
                es[i].p.ans = (max == null ? 0 : max.ans) + es[i].p.cost;
            }
        }
        out.println(max.ans);
        ArrayList<Integer> ids = new ArrayList<Integer>();
        while (max != null) {
            ids.add(max.id);
            max = max.prev;
        }
        out.println(ids.size());
        Collections.reverse(ids);
        for (int i = 0; i < ids.size(); i++) {
            if (i != 0) {
                out.print(" ");
            }
            out.print(ids.get(i));
        }
        out.println();
    }

    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().run();
    }
}
