#include <bits/stdc++.h>
#pragma GCC optimize("O3")
int const N = 2005, M = 105;
using namespace std;
long long n, memo[M][N];
vector<long long> v;
struct item {
  long long d, t, p, ind;
} arr[M];
bool check(item a, item b) { return a.d < b.d; }
long long solve(long long i, long long time) {
  if (i == n) return 0;
  long long &ans = memo[i][time];
  if (~ans) return ans;
  ans = 0;
  if (arr[i].d > time + arr[i].t)
    ans = solve(i + 1, time + arr[i].t) + arr[i].p;
  ans = max(ans, solve(i + 1, time));
  return ans;
}
void build(long long i, long long time) {
  if (i == n) {
    cout << v.size() << endl;
    for (auto i : v) cout << i << " ";
    exit(0);
  }
  if (arr[i].d > time + arr[i].t &&
      memo[i][time] == solve(i + 1, time + arr[i].t) + arr[i].p)
    v.push_back(arr[i].ind), build(i + 1, time + arr[i].t);
  else
    build(i + 1, time);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(memo, -1, sizeof memo);
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> arr[i].t >> arr[i].d >> arr[i].p, arr[i].ind = i + 1;
  sort(arr, arr + n, check);
  cout << solve(0, 0) << endl;
  build(0, 0);
  return 0;
}
