#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
struct item {
  int t, d, p, id;
} a[MAXN];
set<int> tt;
int n, m;
int dp[110][2010];
bool cmp(struct item x, struct item y) {
  if (x.d == y.d) {
    return x.p > y.p;
  }
  return x.d < y.d;
}
int main(int argc, const char* argv[]) {
  scanf("%d", &(n));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &(a[i].t));
    scanf("%d", &(a[i].d));
    scanf("%d", &(a[i].p));
    a[i].id = i;
  }
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= a[i].d - 1; j++) {
      if (j < a[i].t) {
        dp[i][j] = dp[i - 1][j];
      } else
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a[i].t] + a[i].p);
    }
  }
  int ans = 0, ansi = 0;
  for (int i = 1; i <= a[n].d - 1; i++) {
    if (dp[n][i] > ans) {
      ans = dp[n][i];
      ansi = i;
    }
  }
  for (int i = n; i > 0; i--) {
    if (ansi - a[i].t >= 0 &&
        dp[i][ansi] == dp[i - 1][ansi - a[i].t] + a[i].p) {
      tt.insert(i);
      ansi = ansi - a[i].t;
    }
  }
  printf("%d\n", ans);
  int sz = (int)tt.size();
  printf("%d\n", sz);
  for (auto it : tt) {
    printf("%d ", a[it].id);
  }
  printf("\n");
  return 0;
}
