#include <bits/stdc++.h>
using namespace std;
int const bound = 2e6 + 2, N = 2e5 + 2;
long long OO = 1e18;
double eps = 1e-6;
int oo = 1e9, mod = oo + 7;
int n, tt[101], dp[101][3001];
pair<pair<int, int>, pair<int, int> > aa[101];
vector<int> an;
int rec(int idx, int tim) {
  int &ret = dp[idx][tim];
  if (ret != -1) return ret;
  if (idx == n) return ret = 0;
  if (tim >= aa[idx].first.first) return ret = 0;
  if (aa[idx].second.first + tim >= aa[idx].first.first)
    return ret = rec(idx + 1, tim);
  return ret = max(rec(idx + 1, tim), rec(idx + 1, tim + aa[idx].second.first) +
                                          aa[idx].second.second);
}
void print(int idx, int tim) {
  if (idx == n) return;
  if (tim >= aa[idx].first.first) return;
  if (aa[idx].second.first + tim >= aa[idx].first.first) {
    print(idx + 1, tim);
    return;
  }
  int r1 = rec(idx + 1, tim);
  int r2 = rec(idx + 1, tim + aa[idx].second.first) + aa[idx].second.second;
  if (r1 > r2) {
    print(idx + 1, tim);
  } else {
    an.push_back(aa[idx].first.second + 1);
    print(idx + 1, tim + aa[idx].second.first);
  }
}
int main() {
  scanf("%d", &n);
  for (int(i) = 0; (i) < (n); (i)++)
    scanf("%d%d%d", &aa[i].second.first, &aa[i].first.first,
          &aa[i].second.second),
        aa[i].first.second = i;
  sort(aa, aa + n);
  memset(dp, -1, sizeof dp);
  printf("%d\n", rec(0, 0));
  print(0, 0);
  printf("%d\n", (int)an.size());
  for (auto a : an) printf("%d ", a);
  return 0;
}
