#include <bits/stdc++.h>
using namespace std;
struct loop {
  int st, bt, v, num;
} object[2010];
vector<int> v[2010];
int dp[2010], position, i, j, n, answer;
bool cmp(loop a, loop b) { return a.bt < b.bt; }
int main() {
  cin >> n;
  for (i = 1; i <= n; i++)
    scanf("%d%d%d", &object[i].st, &object[i].bt, &object[i].v),
        object[i].num = i;
  sort(object + 1, object + n + 1, cmp);
  for (i = 1; i <= n; i++)
    for (j = object[i].bt - 1; j >= object[i].st; j--)
      if (dp[j - object[i].st] + object[i].v > dp[j]) {
        dp[j] = dp[j - object[i].st] + object[i].v;
        v[j] = v[j - object[i].st];
        v[j].push_back(object[i].num);
      }
  for (i = 0; i <= 2000; i++)
    if (dp[i] > answer) answer = dp[i], position = i;
  printf("%d\n%d\n", answer, v[position].size());
  for (i = 0; i < v[position].size(); i++) printf("%d ", v[position][i]);
}
