#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
struct Item {
  int t, d, p, id;
  bool operator<(const Item &a) const { return d < a.d; }
} items[MAXN];
int dp[2005];
int path[MAXN][2005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> items[i].t >> items[i].d >> items[i].p;
    items[i].id = i;
  }
  sort(items + 1, items + n + 1);
  int last = items[n].d - 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = items[i].d - 1; j >= items[i].t; --j) {
      if (dp[j - items[i].t] + items[i].p > dp[j]) {
        dp[j] = dp[j - items[i].t] + items[i].p;
        path[i][j] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= last; ++i) {
    if (dp[i] > dp[ans]) ans = i;
  }
  cout << dp[ans] << endl;
  vector<int> v;
  for (int i = n; i >= 1; --i) {
    if (path[i][ans]) {
      v.push_back(items[i].id);
      ans -= items[i].t;
    }
  }
  cout << v.size() << endl;
  for (int i = v.size() - 1; i >= 0; --i) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}
