#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
const int MAXM = 2010;
struct node {
  int t, p, d;
  int num;
};
node a[MAXN];
int cmp(const node a, const node b) { return a.d < b.d; }
int f[MAXN][MAXM], pre[MAXN][MAXM];
int save[MAXN];
int main() {
  int n, m = 0, sum = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int t, d, p;
    scanf("%d%d%d", &t, &d, &p);
    if (t < d) {
      a[++sum].num = i;
      a[sum].t = t;
      a[sum].d = d;
      a[sum].p = p;
      m = max(m, a[sum].d);
    }
  }
  sort(a + 1, a + 1 + sum, cmp);
  for (int i = 1; i <= sum; i++) {
    for (int j = 1; j < m; j++) {
      f[i][j] = f[i - 1][j];
      if (j >= a[i].t && j < a[i].d) {
        if (f[i - 1][j - a[i].t] + a[i].p > f[i - 1][j]) {
          f[i][j] = f[i - 1][j - a[i].t] + a[i].p;
          pre[i][j] = 1;
        }
      }
    }
  }
  int ans = 0;
  int tot = 0, pos;
  for (int i = m; i >= 1; i--) {
    if (f[sum][i] >= ans) {
      pos = i;
      ans = f[sum][i];
    }
  }
  for (int i = sum; i >= 1; i--) {
    if (pre[i][pos]) {
      pos -= a[i].t;
      save[++tot] = a[i].num;
    }
  }
  printf("%d\n%d\n", ans, tot);
  for (int i = tot; i >= 1; i--) {
    printf("%d ", save[i]);
  }
  return 0;
}
