#include <bits/stdc++.h>
using namespace std;
struct Node {
  int t, d, p, id;
};
const int maxn = 100;
Node nodes[maxn + 10];
int dp[2100];
vector<int> fire[2100];
bool cmp(Node a, Node b);
int main() {
  int n, ans = 0, index;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &nodes[i].t, &nodes[i].d, &nodes[i].p);
    nodes[i].id = i;
  }
  sort(nodes + 1, nodes + 1 + n, cmp);
  for (int j = 1; j <= n; j++) {
    for (int i = nodes[j].d - 1; i >= nodes[j].t; i--) {
      if (dp[i - nodes[j].t] + nodes[j].p > dp[i]) {
        dp[i] = dp[i - nodes[j].t] + nodes[j].p;
        fire[i] = fire[i - nodes[j].t];
        fire[i].push_back(nodes[j].id);
      }
      if (dp[i] > ans) {
        ans = dp[i];
        index = i;
      }
    }
  }
  printf("%d\n", ans);
  printf("%d\n", fire[index].size());
  for (int i = 0; i < fire[index].size(); i++) {
    if (i) printf(" ");
    printf("%d", fire[index][i]);
  }
  return 0;
}
bool cmp(Node a, Node b) { return a.d < b.d; }
