#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct item {
  long long t, d, p, idx;
};
item sh[200005];
bool cmp(item x, item y) { return x.d < y.d; }
long long n;
long long dp[105][2005];
long long sol(long long i, long long cur) {
  if (i == n) return 0;
  if (~dp[i][cur]) return dp[i][cur];
  if (sh[i].t + cur >= sh[i].d) return dp[i][cur] = sol(i + 1, cur);
  return dp[i][cur] = max(sh[i].p + sol(i + 1, cur + sh[i].t), sol(i + 1, cur));
}
vector<long long> ans;
void print(long long i, long long cur) {
  if (i == n) return;
  if (sh[i].t + cur >= sh[i].d) {
    print(i + 1, cur);
  } else if (sh[i].p + sol(i + 1, cur + sh[i].t) > sol(i + 1, cur)) {
    ans.push_back(sh[i].idx);
    print(i + 1, cur + sh[i].t);
  } else
    print(i + 1, cur);
}
void solve() {
  long long i, j, k, l, r, m, a, b, c, d, x, y, z, t;
  cin >> n;
  memset(dp, -1, sizeof dp);
  for (i = 0; i < n; i++) {
    cin >> sh[i].t >> sh[i].d >> sh[i].p;
    sh[i].idx = i + 1;
  }
  sort(sh, sh + n, cmp);
  cout << sol(0, 0) << endl;
  print(0, 0);
  cout << ans.size() << endl;
  for (auto &cv : ans) {
    cout << cv << ' ';
  }
  cout << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
