#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 3, M = 1e2 + 2;
struct node {
  int i, t, d, p;
  bool operator<(node other) const { return d < other.d; }
} a[N];
int n, memo[M][N];
int go(int i, int time) {
  if (i == n) return 0;
  int &ret = memo[i][time];
  if (~ret) return ret;
  ret = go(i + 1, time);
  if (time + a[i].t < a[i].d) {
    ret = max(ret, go(i + 1, time + a[i].t) + a[i].p);
  }
  return ret;
}
vector<int> result;
void build(int i, int time) {
  if (i == n) return;
  if (go(i + 1, time) == memo[i][time]) {
    build(i + 1, time);
  } else {
    result.push_back(a[i].i);
    build(i + 1, time + a[i].t);
  }
}
int main() {
  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].i = i + 1;
  }
  sort(a, a + n);
  memset(memo, -1, sizeof memo);
  printf("%d\n", go(0, 0));
  build(0, 0);
  printf("%d\n", result.size());
  for (auto x : result) {
    printf("%d ", x);
  }
  return 0;
}
