#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int M = 2005;
pair<pair<int, int>, pair<int, int> > adj[N];
int dp[M];
vector<int> way[M];
bool cmp(pair<pair<int, int>, pair<int, int> > a,
         pair<pair<int, int>, pair<int, int> > b) {
  return a.second.second < b.second.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int t, d, p;
    cin >> t >> d >> p;
    adj[i] = make_pair(make_pair(t, i), make_pair(p, d));
  }
  sort(adj + 1, adj + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    for (int j = adj[i].second.second - 1; j >= adj[i].first.first; j--) {
      if (dp[j] < dp[j - adj[i].first.first] + adj[i].second.first) {
        dp[j] = dp[j - adj[i].first.first] + adj[i].second.first;
        way[j] = way[j - adj[i].first.first];
        way[j].emplace_back(adj[i].first.second);
      }
    }
  }
  int ans1 = 0;
  vector<int> ans2;
  for (int i = 0; i <= M - 1; i++) {
    if (dp[i] > ans1) {
      ans1 = dp[i];
      ans2 = way[i];
    }
  }
  cout << ans1 << "\n" << ans2.size() << "\n";
  for (auto op : ans2) {
    cout << op << " ";
  }
}
