#include <bits/stdc++.h>
using namespace std;
const int maxn = 105, maxm = 100005;
struct xjh {
  int t, d, p, id;
} a[maxn];
int n, m, ans, f[maxm], vis[maxn][maxm];
int pp[maxn], cnt, res, las;
inline bool cmp(xjh a, xjh b) {
  if (a.d == b.d) return a.p < b.p;
  return a.d < b.d;
}
inline int read() {
  int sum = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();
  return sum;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i].t = read();
    a[i].d = read();
    a[i].p = read();
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++)
    for (int j = a[i].d - 1; j >= a[i].t; j--)
      if (f[j] < f[j - a[i].t] + a[i].p)
        f[j] = f[j - a[i].t] + a[i].p, vis[i][j] = 1;
  for (int i = 1; i <= a[n].d; i++)
    if (ans < f[i]) ans = f[i], las = i;
  printf("%d\n", ans);
  for (int i = n; i >= 1; i--)
    if (vis[i][las]) las -= a[i].t, pp[++cnt] = a[i].id;
  printf("%d\n", cnt);
  reverse(pp + 1, pp + cnt + 1);
  for (int i = 1; i <= cnt; i++) printf("%d ", pp[i]);
  return 0;
}
