#include <bits/stdc++.h>
using namespace std;
const int maxn = 111;
int a[maxn], b[maxn], c[maxn], id[maxn], d[111][2009], pre[111][2009], num = 0;
void pri(int xx, int mx) {
  if (xx == 0) {
    printf("%d\n", num);
    return;
  }
  if (pre[xx][mx] != mx) num++;
  pri(xx - 1, pre[xx][mx]);
  if (pre[xx][mx] != mx) {
    printf("%d ", id[xx]);
  }
}
int main() {
  int n, mx = 0, ma = 0, xx;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    id[i] = i;
  }
  sort(id + 1, id + n + 1, [](int x, int y) { return b[x] < b[y]; });
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    int x = id[i];
    for (int k = 0; k < 2009; ++k) d[i][k] = d[i - 1][k], pre[i][k] = k;
    for (int j = b[x]; j > a[x]; --j) {
      if (d[i - 1][j - a[x]] + c[x] > d[i][j]) {
        d[i][j] = d[i - 1][j - a[x]] + c[x];
        pre[i][j] = j - a[x];
      }
    }
  }
  for (int i = 0; i < 2009; ++i) {
    if (d[n][i] > ma) ma = d[n][i], mx = i;
  }
  printf("%d\n", ma);
  pri(n, mx);
  printf("\n");
  return 0;
}
