import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

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

        Problem(int s, int t, int c, int id) {
            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 +
                    ", prev=" + prev +
                    '}';
        }
    }

    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(), i + 1);
        }
        Arrays.sort(ps);
        TreeSet<Problem> inProgress = new TreeSet<Problem>(new Comparator<Problem>() {
            @Override
            public int compare(Problem o1, Problem o2) {
                if (o1.end() != o2.end()) {
                    return o1.end() - o2.end();
                } else {
                    return o1.id - o2.id;
                }
            }
        });
        int max = 0;
        Problem currentMax = null;
        for (int i = 0; i < n; i++) {
            while (!inProgress.isEmpty() && inProgress.first().end() <= ps[i].start) {
                Problem p = inProgress.first();
                if (currentMax == null || currentMax.ans < p.ans) {
                    p.prev = currentMax;
                    currentMax = p;
                }
                inProgress.remove(p);
            }
            ps[i].ans = (currentMax == null ? 0 : currentMax.ans) + ps[i].cost;
            inProgress.add(ps[i]);
            if (currentMax == null || currentMax.ans < ps[i].ans) {
                ps[i].prev = currentMax;
                currentMax = ps[i];
            }
            max = Math.max(max, ps[i].ans);
        }
        //System.err.println(Arrays.toString(ps));
        out.println(max);
        ArrayList<Integer> ids = new ArrayList<Integer>();
        while (currentMax != null) {
            ids.add(currentMax.id);
            currentMax = currentMax.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_nlogn().run();
    }
}
