#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char s = getchar();
  while ((s < '0' || s > '9') && s > 0) {
    if (s == '-') f *= -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 1) + (x << 3) + s - '0';
    s = getchar();
  }
  return x * f;
}
int n = read(), dp[105][2005], pr[105][2005], ans;
struct itn {
  int p, t, d, id;
  itn() {}
  itn(int P, int D, int T, int I) { p = P, d = D, t = T, id = I; }
} a[105];
vector<int> A;
inline bool cmp(itn a, itn b) { return a.d < b.d; }
int main() {
  memset(pr, -1, sizeof(pr));
  for (int i = 1; i <= n; i++) a[i] = itn(read(), read(), read(), i);
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 2000; j++) {
      dp[i][j] = dp[i - 1][j], pr[i][j] = j;
      if (j >= a[i].t && j < a[i].d)
        if (dp[i - 1][j - a[i].t] + a[i].p > dp[i][j])
          dp[i][j] = dp[i - 1][j - a[i].t] + a[i].p, pr[i][j] = j - a[i].t;
    }
  for (int i = 1; i < 2000; i++)
    if (dp[n][i] > dp[n][ans]) ans = i;
  printf("%d\n", dp[n][ans]);
  for (int i = n; i > 0; i--) {
    if (pr[i][ans] != ans) A.push_back(a[i].id);
    ans = pr[i][ans];
  }
  printf("%d\n", A.size());
  for (int i = A.size() - 1; i >= 0; i--)
    printf("%d", A[i]), putchar(i ? ' ' : '\n');
  return 0;
}
