#include <bits/stdc++.h>
using namespace std;
struct data {
  int id, t, d, p;
};
data a[105];
int n, ii, jj, res = 0, f[105][2005], Trace[105][2005];
vector<int> rs;
bool cmp(data x1, data x2) { return x1.d < x2.d; }
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; 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 = 1; j <= 2000; j++) {
      f[i][j] = f[i - 1][j];
      Trace[i][j] = j;
      if (j < a[i].d && a[i].t <= j &&
          f[i][j] < f[i - 1][j - a[i].t] + a[i].p) {
        f[i][j] = f[i - 1][j - a[i].t] + a[i].p;
        Trace[i][j] = j - a[i].t;
      }
      if (res < f[i][j]) {
        res = f[i][j];
        ii = i;
        jj = j;
      }
    }
  while (ii > 0) {
    if (jj != Trace[ii][jj]) rs.push_back(a[ii].id);
    jj = Trace[ii][jj];
    ii--;
  }
  cout << res << "\n" << rs.size() << "\n";
  for (int i = rs.size() - 1; i >= 0; i--) cout << rs[i] << ' ';
}
