#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 100;
int dp[101][2001], pr[101][2001];
struct Triple {
  int t, d, p, num;
  Triple() = default;
};
bool cmp(Triple a, Triple b) { return a.d < b.d; }
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<Triple> a(n);
  int mx_d = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].t >> a[i].d >> a[i].p;
    a[i].num = i + 1;
    mx_d = max(mx_d, a[i].d);
  }
  mx_d++;
  sort(a.begin(), a.end(), cmp);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < mx_d; ++j) pr[i][j] = -1;
  for (int i = 0; i < n; ++i) {
    if (i > 0) {
      for (int j = 0; j < mx_d; ++j) dp[i][j] = dp[i - 1][j];
    }
    for (int j = a[i].d - a[i].t - 1; j >= 0; --j) {
      if (dp[i][j + a[i].t] < dp[i][j] + a[i].p) {
        dp[i][j + a[i].t] = dp[i][j] + a[i].p;
        pr[i][j + a[i].t] = 1;
      }
    }
  }
  int mx_ans = 0, i1 = n - 1, j1 = 0;
  for (int i = 0; i < mx_d; ++i) {
    if (mx_ans < dp[n - 1][i]) {
      j1 = i;
      mx_ans = dp[n - 1][i];
    }
  }
  cout << mx_ans << '\n';
  vector<int> ans;
  while (i1 >= 0 && j1 >= 0) {
    if (pr[i1][j1] == -1) {
      i1--;
    } else {
      ans.push_back(a[i1].num);
      j1 -= a[i1].t;
      i1--;
    }
  }
  cout << ans.size() << '\n';
  for (int i = ans.size() - 1; i >= 0; --i) cout << ans[i] << ' ';
  return 0;
}
