#include <bits/stdc++.h>
using namespace std;
struct node {
  int t, d, p, id;
  bool operator<(const node &b) const { return d < b.d; }
} a[105];
int dp[2005];
vector<int> ans[2005];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i].t, &a[i].d, &a[i].p);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = a[i].d - 1; j >= a[i].t; j--) {
      if (dp[j] < dp[j - a[i].t] + a[i].p) {
        dp[j] = dp[j - a[i].t] + a[i].p;
        ans[j].clear();
        ans[j] = ans[j - a[i].t];
        ans[j].push_back(a[i].id);
      }
    }
  }
  int maxx = 0, ansi;
  for (int i = 0; i < 2005; i++) {
    if (maxx < dp[i]) {
      maxx = dp[i];
      ansi = i;
    }
  }
  printf("%d\n", maxx);
  printf("%d\n", ans[ansi].size());
  for (int i = 0; i < (int)ans[ansi].size(); i++) {
    if (i) printf(" ");
    printf("%d", ans[ansi][i]);
  }
  puts("");
  return 0;
}
