#include <bits/stdc++.h>
using namespace std;
int dp[105][2025], dp2[105][2025];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<array<int, 4>> v;
  for (int i = 0; i < n; i++) {
    int d, p, t;
    cin >> t >> d >> p;
    v.push_back({d, t, p, i});
  }
  sort(v.begin(), v.end());
  for (int i = n - 1; i >= 0; i--) {
    int di = v[i][0], ti = v[i][1], pi = v[i][2];
    for (int t = 0; t <= 2000; t++) {
      int t2 = t + ti;
      if (t2 < di) {
        if (dp[i][t] <= pi + dp[i + 1][t2]) {
          dp[i][t] = pi + dp[i + 1][t2];
          dp2[i][t] = i;
        }
      }
      if (dp[i][t] <= dp[i + 1][t]) {
        dp[i][t] = dp[i + 1][t];
        dp2[i][t] = i + 1;
      }
    }
  }
  cout << dp[0][0] << '\n';
  vector<int> ans;
  int i = 0, t = 0;
  while (i < n) {
    int ti = v[i][1];
    if (dp2[i][t] == i) {
      ans.push_back(i);
      t += ti;
    }
    i++;
  }
  cout << ans.size() << '\n';
  for (auto elm : ans) {
    cout << v[elm][3] + 1 << ' ';
  }
  return 0;
}
