#include <bits/stdc++.h>
using namespace std;
const int T = 2050;
int n, dp[105][T], pos[105][T], pre[105][T], val;
vector<int> ans;
struct Produst {
  int t, d, p, add;
} pro[105];
inline bool cmp(Produst a, Produst b) { return a.d < b.d; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &pro[i].t, &pro[i].d, &pro[i].p);
    pro[i].add = i;
  }
  sort(pro + 1, pro + n + 1, cmp);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < T; j++) {
      dp[i][j] = dp[i - 1][j];
      pos[i][j] = pos[i - 1][j];
      if (pro[i].d > j && j - pro[i].t >= 0)
        if (dp[i][j] < dp[i - 1][j - pro[i].t] + pro[i].p) {
          dp[i][j] = dp[i - 1][j - pro[i].t] + pro[i].p;
          pre[i][j] = pos[i - 1][j - pro[i].t];
          pos[i][j] = i * T + j;
        }
    }
  int f = n, s = 0;
  for (int i = 0; i < T; i++)
    if (dp[n][i] > val) {
      val = dp[n][i];
      s = i;
    }
  if (val == 0) return printf("0\n0\n"), 0;
  f = pos[f][s] / T;
  int x;
  do {
    x = pre[f][s];
    ans.push_back(pro[f].add);
    f = x / T, s = x % T;
  } while (x);
  printf("%d\n%d\n", val, (int)ans.size());
  for (int i = ans.size() - 1; i >= 0; i--)
    printf(i == 0 ? "%d\n" : "%d ", ans[i]);
  return 0;
}
