import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class olympiad_sm_greedy4 {
    class Problem implements Comparable<Problem> {
        int start, time, cost, id;

        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 +
                    ", id=" + id +
                    '}';
        }
    }

    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);
        }
        TreeSet<Problem> used = new TreeSet<Problem>();
        Arrays.sort(ps, new Comparator<Problem>() {
            @Override
            public int compare(Problem o1, Problem o2) {
                return o1.cost - o2.cost;
            }
        });
        long ans = 0;
        for (int i = 0; i < ps.length; i++) {
            Problem a = used.floor(ps[i]);
            if (a != null && a.start + a.time > ps[i].start) {
                continue;
            }
            Problem b = used.ceiling(ps[i]);
            if (b != null && b.start < ps[i].start + ps[i].time) {
                continue;
            }
            used.add(ps[i]);
            ans += ps[i].cost;
        }

        out.println(ans);
        out.println(used.size());
        for (Problem p : used) {
            out.print(p.id + " ");
        }

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