#include <bits/stdc++.h>
using namespace std;
int n, dp[105][3005];
pair<int, int> prv[105][3005];
struct data {
  int t, d, p, id;
  data() {}
  bool operator<(const data &val) const { return d < val.d; }
} a[105];
int l, ans[105];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].t, &a[i].d, &a[i].p);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1);
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < 3000; i++) dp[n + 1][i] = 0;
  for (int i = n; i > 0; i--) {
    for (int t = 0; t < 3000; t++) {
      if (dp[i + 1][t] != -1) {
        dp[i][t] = dp[i + 1][t];
        prv[i][t] = {i + 1, t};
      }
      if (dp[i + 1][t + a[i].t] != -1 && a[i].d > t + a[i].t &&
          dp[i + 1][t + a[i].t] + a[i].p > dp[i][t]) {
        dp[i][t] = dp[i + 1][t + a[i].t] + a[i].p;
        prv[i][t] = {i + 1, t + a[i].t};
      }
    }
  }
  int i = 1, t = 0;
  while (i <= n) {
    int nt = prv[i][t].second;
    if (nt > t) ans[++l] = a[i].id;
    t = nt;
    i++;
  }
  printf("%d\n", dp[1][0]);
  printf("%d\n", l);
  for (int i = 1; i <= l; i++) {
    printf("%d", ans[i]);
    printf(i == l ? "\n" : " ");
  }
  return 0;
}
