#include <bits/stdc++.h>
using namespace std;
template <class C>
void mini(C& _a4, C _b4) {
  _a4 = min(_a4, _b4);
}
template <class C>
void maxi(C& _a4, C _b4) {
  _a4 = max(_a4, _b4);
}
int n;
vector<vector<int> > V;
int P[200];
int T[200];
int X[2100][2100];
int dp[2100];
int main() {
  int n;
  scanf("%d", &n);
  ;
  for (int i = (0); i <= ((int)(n)-1); i++) {
    int nr = i + 1;
    int t, d, p;
    scanf("%d", &t);
    ;
    scanf("%d", &d);
    ;
    scanf("%d", &p);
    ;
    P[nr] = p;
    T[nr] = t;
    --d;
    V.push_back(vector<int>{d, t, p, nr});
  }
  sort((V).begin(), (V).end());
  for (vector<int> v : V) {
    int d = v[0];
    int t = v[1];
    int p = v[2];
    int nr = v[3];
    for (int i = d; i >= t; --i)
      if (dp[i - t] + p > dp[i]) {
        dp[i] = dp[i - t] + p;
        X[i][dp[i]] = nr;
      }
  }
  int maxn = 0;
  for (int i = (0); i <= ((int)(2100) - 1); i++)
    if (dp[i] > dp[maxn]) maxn = i;
  printf("%d\n", dp[maxn]);
  int val = dp[maxn];
  stack<int> S;
  while (val > 0) {
    int nr = X[maxn][val];
    S.push(nr);
    maxn -= T[nr];
    val -= P[nr];
    assert(((int)(S).size()) < 10000);
  }
  printf("%d\n", ((int)(S).size()));
  while (((int)(S).size()) > 0) {
    printf("%d ", S.top());
    S.pop();
  }
  puts("");
  return 0;
}
