#include <bits/stdc++.h>
using namespace std;
struct Item {
  int id, t, d, p;
  Item(int _id = 0, int _t = 0, int _d = 0, int _p = 0)
      : id(_id), t(_t), d(_d), p(_p) {}
  bool operator<(const Item &rhs) const { return d < rhs.d; }
};
constexpr int kN = 101, kT = 2001;
Item a[kN];
int dp[kN][kT];
int tk[kN][kT];
int main() {
  int n;
  scanf("%d", &n);
  int t, d, p;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d %d", &t, &d, &p);
    a[i] = Item(i + 1, t, d, p);
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j + a[i].t < a[i].d; ++j) {
      if (dp[i][j] + a[i].p > dp[i + 1][j + a[i].t]) {
        dp[i + 1][j + a[i].t] = dp[i][j] + a[i].p;
        tk[i + 1][j + a[i].t] = 1;
      }
    }
    for (int j = 0; j < kT; ++j) {
      if (dp[i][j] > dp[i + 1][j]) {
        dp[i + 1][j] = dp[i][j];
        tk[i + 1][j] = 0;
      }
    }
  }
  int x = 0;
  for (int i = 0; i < a[n - 1].d; ++i) {
    if (dp[n][i] > dp[n][x]) {
      x = i;
    }
  }
  printf("%d\n", dp[n][x]);
  vector<int> ans;
  for (int i = n; i > 0; --i) {
    if (tk[i][x]) {
      ans.push_back(a[i - 1].id);
      x -= a[i - 1].t;
    }
  }
  reverse(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
