#include <bits/stdc++.h>
using namespace std;
struct node {
  int t, d, p, id;
} s[110];
int dp[2010];
vector<int> v[2010];
int cmp(node a, node b) { return a.d < b.d; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &s[i].t, &s[i].d, &s[i].p), s[i].id = i;
  }
  sort(s + 1, s + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    if (s[i].d - s[i].t <= 0) continue;
    for (int j = s[i].d - 1; j - s[i].t >= 0; j--) {
      if (dp[j] < dp[j - s[i].t] + s[i].p) {
        dp[j] = dp[j - s[i].t] + s[i].p;
        v[j] = v[j - s[i].t];
        v[j].push_back(s[i].id);
      }
    }
  }
  int best = 0, bestI = 0;
  for (int i = 0; i <= 2000; i++) {
    if (dp[i] > best) {
      best = dp[i];
      bestI = i;
    }
  }
  printf("%d\n", best);
  printf("%d\n", v[bestI].size());
  for (int i = 0; i < v[bestI].size(); i++) printf("%d ", v[bestI][i]);
}
