#include <bits/stdc++.h>
using namespace std;
int n;
int cache[2005][105];
pair<int, int> link[2005][105];
struct Item {
  int i, t, d, p;
} items[105];
int dp(const int t, const int idx) {
  if (idx >= n) return 0;
  int& ret = cache[t][idx];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = idx; i < n; i++) {
    Item item = items[i];
    if (t + item.t < item.d) {
      auto cur = item.p + dp(t + item.t, i + 1);
      if (cur > ret) {
        link[t][idx] = make_pair(t + item.t, i + 1);
        ret = cur;
      }
    }
  }
  return ret;
}
void follow(vector<int>& ret) {
  auto next = link[0][0];
  while (next.second > 0) {
    ret.push_back(items[next.second - 1].i);
    next = link[next.first][next.second];
  }
}
int main() {
  memset(cache, -1, sizeof(cache));
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    items[i].i = i + 1;
    cin >> items[i].t >> items[i].d >> items[i].p;
  }
  sort(items, items + n,
       [](const Item& a, const Item& b) { return a.d < b.d; });
  cout << dp(0, 0) << endl;
  vector<int> ret;
  follow(ret);
  cout << ret.size() << endl;
  for (int i = 0; i < ret.size(); i++) cout << ret[i] << " ";
  return 0;
}
