#include <bits/stdc++.h>
using namespace std;
struct itm {
  int t, d, p, id;
  bool operator<(const itm &a) const { return d < a.d; }
};
int n;
itm a[110];
int res[110][2200], tk[110][2200];
int dp(int id, int T) {
  if (id == n) return 0;
  if (res[id][T] != -1) return res[id][T];
  int w1 = 0, w2 = 0;
  if (T + a[id].t < a[id].d) w1 = a[id].p + dp(id + 1, T + a[id].t);
  w2 = dp(id + 1, T);
  if (w1 > w2) tk[id][T] = 1;
  return res[id][T] = max(w1, w2);
}
int main() {
  memset(res, -1, sizeof(res));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &a[i].t, &a[i].d, &a[i].p);
    a[i].id = i + 1;
  }
  sort(a, a + n);
  int id = 0, T = 0;
  printf("%d\n", dp(id, T));
  vector<int> anw;
  while (id < n) {
    if (tk[id][T]) T += a[id].t, anw.push_back(a[id].id);
    id++;
  }
  printf("%d\n", int(anw.size()));
  for (int i = 0; i < int(anw.size()); i++) {
    if (i) printf(" ");
    printf("%d", anw[i]);
  }
  puts("");
}
