#include <bits/stdc++.h>
using namespace std;
struct nd {
  int t, d, p, id;
} a[105];
int d[2005];
vector<int> v[2005], ans1;
int cmp(nd x, nd y) { return x.d < y.d; }
int main() {
  if (0) {
    if (0) {
      freopen("daun.in", "r", stdin);
      freopen("daun.out", "w", stdout);
    } else {
      freopen("input.txt", "r", stdin);
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= 105; i++) {
    cin >> a[i].t >> a[i].d >> a[i].p;
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    for (int j = a[i].d - 1; j >= a[i].t; j--) {
      if (d[j] < d[j - a[i].t] + a[i].p) {
        d[j] = d[j - a[i].t] + a[i].p;
        v[j] = v[j - a[i].t];
        v[j].push_back(a[i].id);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= 2000; i++) {
    if (d[i] > ans) {
      ans = d[i];
      ans1 = v[i];
    }
  }
  cout << ans << endl << ans1.size() << endl;
  for (int i = 0; i < ans1.size(); i++) {
    cout << ans1[i] << ' ';
  }
}
