#include <bits/stdc++.h>
using namespace std;
struct node {
  int t, d, p, tot;
} a[200];
int f[3000];
bool cmp(node x, node y) {
  if (x.d != y.d)
    return x.d < y.d;
  else
    return x.t > y.t;
}
bitset<150> ans[2050];
int cc[2050];
int main() {
  int n;
  scanf("%d", &n);
  int ma = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &a[i].t, &a[i].d, &a[i].p);
    ma = max(ma, a[i].d);
    a[i].tot = i;
  }
  sort(a + 1, a + n + 1, cmp);
  f[0] = 0;
  ans[0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = a[i].d - 1; j >= a[i].t; --j)
      if (f[j] < f[j - a[i].t] + a[i].p) {
        f[j] = f[j - a[i].t] + a[i].p;
        ans[j] = ans[j - a[i].t];
        ans[j].set(i);
      }
  ma = 0;
  int num = 0;
  for (int i = a[n].d - 1; i >= 0; --i)
    if (f[i] > ma) {
      ma = f[i];
      num = i;
    }
  printf("%d\n", ma);
  int tot = 0;
  for (int i = 1; i <= n; ++i)
    if (ans[num].test(i)) {
      ++tot;
      cc[tot] = a[i].tot;
    }
  printf("%d\n", tot);
  for (int i = 1; i <= tot; ++i)
    if (i == 1)
      printf("%d", cc[i]);
    else
      printf(" %d", cc[i]);
  printf("\n");
  return 0;
}
