#include <bits/stdc++.h>
using namespace std;
int dp[2005];
vector<int> ve[2005];
struct node {
  int c, d, w, id;
} num[105];
bool cmp(node a, node b) {
  if (a.d != b.d) return a.d < b.d;
  if (a.c != b.c) return a.c < b.c;
  return a.w > b.w;
}
int main() {
  int n;
  cin >> n;
  int up = 0;
  for (int i = 0; i < n; i++) {
    cin >> num[i].c >> num[i].d >> num[i].w;
    up = max(up, num[i].d);
    num[i].id = i + 1;
  }
  sort(num, num + n, cmp);
  memset(dp, -1, sizeof dp);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    int c = num[i].c;
    int d = num[i].d;
    int w = num[i].w;
    for (int v = up - 1; v >= c; v--) {
      if (v < d && dp[v - c] != -1) {
        if (dp[v] < dp[v - c] + w) {
          dp[v] = dp[v - c] + w;
          ve[v].clear();
          ve[v] = ve[v - c];
          ve[v].push_back(num[i].id);
        }
      }
    }
  }
  int tmp = 0;
  for (int i = 0; i <= up; i++) tmp = max(tmp, dp[i]);
  for (int i = 0; i <= up; i++) {
    if (tmp == dp[i]) {
      cout << dp[i] << endl;
      if (ve[i].size()) {
        cout << ve[i].size() << endl;
        for (auto x : ve[i]) cout << x << " ";
        cout << endl;
      } else
        cout << 0 << endl;
      break;
    }
  }
}
