#include <bits/stdc++.h>
struct dta {
  int t, d, p, id;
};
using namespace std;
bool operator<(const dta &x, const dta &y) {
  return (x.d < y.d || (x.d == y.d && x.t < y.t));
}
int n, trace[110][110 * 20], F[110][110 * 20], res;
dta A[110];
vector<int> resa;
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);
  for (int i = 1; i <= n; i++) A[i].id = i;
  sort(A + 1, A + 1 + n);
  memset(trace, 0, sizeof(trace));
  memset(F, 0, sizeof(F));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= A[i].d - 1; j++) {
      F[i][j] = F[i - 1][j];
      trace[i][j] = j;
      if (j - A[i].t >= 0 && F[i - 1][j - A[i].t] + A[i].p > F[i][j]) {
        F[i][j] = F[i - 1][j - A[i].t] + A[i].p;
        trace[i][j] = j - A[i].t;
      }
    }
  int tmax = 0;
  res = 0;
  for (int i = 1; i <= A[n].d; i++) {
    if (tmax < F[n][i]) tmax = F[n][i], res = i;
  }
  int xcur = n, ycur = res;
  while (xcur > 0) {
    if (trace[xcur][ycur] != ycur) resa.push_back(A[xcur].id);
    ycur = trace[xcur][ycur];
    xcur--;
  }
  printf("%d\n%d\n", tmax, resa.size());
  if (!resa.empty()) {
    reverse(resa.begin(), resa.end());
    for (int i = 0; i <= resa.size() - 1; i++) printf("%d ", resa[i]);
  }
  return 0;
}
