#include <bits/stdc++.h>
using namespace std;
struct data {
  int t, d, p, id;
  int operator<(const data &b) const { return d < b.d; }
} a[105];
int F[105][2005], G[105][2005], ans[105], n, i, j, Ans, J, T;
void Max(int x, int y, int z, int w) {
  if (z <= F[x][y]) return;
  F[x][y] = z;
  G[x][y] = w;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    scanf("%d%d%d", &a[i].t, &a[i].d, &a[i].p), a[i].id = i,
                                                T = max(T, --a[i].d);
  sort(a + 1, a + n + 1);
  for (i = 0; i < n; i++)
    for (j = 0; j <= T; j++) {
      Max(i + 1, j, F[i][j], 0);
      if (j + a[i + 1].t <= a[i + 1].d)
        Max(i + 1, j + a[i + 1].t, F[i][j] + a[i + 1].p, 1);
    }
  for (j = 0; j <= T; j++)
    if (F[n][j] > Ans) Ans = F[n][j], J = j;
  printf("%d\n", Ans);
  for (i = n, j = J; i; i--)
    if (G[i][j] == 1) ans[++*ans] = a[i].id, j -= a[i].t;
  printf("%d\n", *ans);
  reverse(ans + 1, ans + (*ans) + 1);
  for (i = 1; i <= *ans; i++) printf("%d ", ans[i]);
}
