#include <bits/stdc++.h>
using namespace std;
const int MX = 1e2 + 10;
const int mod = 1e9 + 7;
const long long int inf = 1LL << 62;
int dx4[] = {0, 0, -1, 1};
int dy4[] = {1, -1, 0, 0};
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
long long int n;
long long int ar[MX], d[MX], t[MX], p[MX];
long long int dp[110][2020];
vector<long long int> vec;
bool cmp(const long long int& a, const long long int& b) {
  if (d[a] != d[b]) return d[a] < d[b];
  return t[a] < t[b];
}
long long int rec(long long int pos, long long int tot) {
  if (pos == n) return 0;
  long long int& ret = dp[pos][tot];
  if (~ret) return ret;
  long long int idx = ar[pos];
  if (tot + t[idx] >= d[idx]) {
    return ret = rec(pos + 1, tot);
  }
  ret = max(ret, rec(pos + 1, tot + t[idx]) + p[idx]);
  ret = max(ret, rec(pos + 1, tot));
  return ret;
}
void find_path(long long int pos, long long int tot) {
  if (pos == n) return;
  long long int idx = ar[pos];
  if (tot + t[idx] >= d[idx]) {
    find_path(pos + 1, tot);
    return;
  }
  if (rec(pos + 1, tot) >= rec(pos + 1, tot + t[idx]) + p[idx])
    find_path(pos + 1, tot);
  else
    vec.push_back(idx), find_path(pos + 1, tot + t[idx]);
  return;
}
int main() {
  memset(dp, -1, sizeof(dp));
  long long int m, k, q, cnt = 0, sum = 0, mx = -inf, mn = inf;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &t[i], &d[i], &p[i]);
    ar[i] = i;
  }
  sort(ar, ar + n, cmp);
  long long int res = rec(0, 0);
  find_path(0, 0);
  cout << (res) << endl;
  cout << (vec.size()) << endl;
  for (auto it : vec) cout << (it + 1) << " ";
  return 0;
}
