#include <bits/stdc++.h>
int n, dp[105][2005];
struct node {
  int t, d, p, idx;
  bool operator<(const node &_o) const { return d < _o.d; }
} a[105];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].t, &a[i].d, &a[i].p);
    a[i].idx = i;
  }
  std::sort(a + 1, a + n + 1);
  int last = a[n].d;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= last; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j < a[i].d && j >= a[i].t)
        dp[i][j] = std::max(dp[i][j], dp[i - 1][j - a[i].t] + a[i].p);
    }
  }
  int ans = -1, idx;
  std::vector<int> v;
  for (int i = 0; i <= last; i++) {
    if (dp[n][i] > ans) {
      ans = dp[n][i];
      idx = i;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (dp[i][idx] != dp[i - 1][idx]) {
      v.push_back(a[i].idx);
      idx -= a[i].t;
    } else {
      int j;
      for (j = idx; j >= 0 && dp[i - 1][j] == dp[i - 1][idx]; j--) {
      }
      idx = ++j;
    }
  }
  std::reverse(v.begin(), v.end());
  printf("%d\n%d\n", ans, (int)v.size());
  for (int i = 0; i < v.size(); i++) printf("%d ", v[i]);
  return 0;
}
