#include <bits/stdc++.h>
using namespace std;
const int N = 103, M = 2003;
int n, f[M], wh[M];
int a[N], m;
struct item {
  int t, d, p, id;
  inline int operator<(const item& p) const { return d < p.d; }
} s[N];
vector<int> ls[M];
int main() {
  scanf("%d", &n);
  int i, j;
  for (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);
  for (i = 1; i <= n; ++i) {
    for (j = s[i].d - 1; j >= s[i].t; --j) {
      if (f[j - 1] > f[j]) {
        f[j] = f[j - 1];
        ls[j] = ls[j - 1];
      }
      const int l = f[j - s[i].t] + s[i].p;
      if (f[j] < l) {
        f[j] = l;
        ls[j] = ls[j - s[i].t];
        ls[j].push_back(s[i].id);
      }
    }
  }
  int ans = 0;
  for (i = 1; i <= 2000; ++i) {
    if (f[i] > f[ans]) ans = i;
  }
  printf("%d\n", f[ans]);
  printf("%d\n", ls[ans].size());
  for (i = 0; i < ls[ans].size(); ++i) printf("%d ", ls[ans][i]);
  return 0;
}
