#include <bits/stdc++.h>
using namespace std;
pair<pair<int, int>, pair<int, int>> a[110];
pair<int, pair<int, bool>> dp[110][2040];
int n;
int solve(int x, int y) {
  if (x > n) return 0;
  if (dp[x][y].first) return dp[x][y].first;
  if (y + a[x].first.second >= a[x].first.first) {
    dp[x][y].second.first = y;
    return dp[x][y].first = solve(x + 1, y);
  } else {
    if (a[x].second.first + solve(x + 1, y + a[x].first.second) >
        solve(x + 1, y)) {
      dp[x][y].second.second = 1;
      dp[x][y].second.first = y + a[x].first.second;
      return dp[x][y].first =
                 a[x].second.first + solve(x + 1, y + a[x].first.second);
    } else {
      dp[x][y].second.first = y;
      return dp[x][y].first = solve(x + 1, y);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i].first.second >> a[i].first.first >> a[i].second.first,
        a[i].second.second = i;
  sort(a + 1, a + n + 1);
  cout << solve(1, 0) << endl;
  vector<int> ans;
  int x = 1, y = 0;
  while (x <= n) {
    if (dp[x][y].second.second) ans.push_back(a[x].second.second);
    int t2 = dp[x][y].second.first;
    x++;
    y = t2;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
