#include <bits/stdc++.h>
using namespace std;
long long inf = 1e14;
char en = '\n';
long long INF = inf;
vector<vector<long long>> cost;
long long hungarian(vector<vector<long long>> cost) {
  long long n = (long long)cost.size() - 1;
  long long m = (long long)cost[0].size() - 1;
  vector<long long> u(n + 1), v(m + 1), p(m + 1), way(m + 1);
  for (long long i = 1; i <= n; ++i) {
    p[0] = i;
    long long j0 = 0;
    vector<long long> minv(m + 1, INF);
    vector<char> used(m + 1, false);
    do {
      used[j0] = true;
      long long i0 = p[j0], delta = INF, j1;
      for (long long j = 1; j <= m; ++j)
        if (!used[j]) {
          long long cur = cost[i0][j] - u[i0] - v[j];
          if (cur < minv[j]) minv[j] = cur, way[j] = j0;
          if (minv[j] < delta) delta = minv[j], j1 = j;
        }
      for (long long j = 0; j <= m; ++j)
        if (used[j])
          u[p[j]] += delta, v[j] -= delta;
        else
          minv[j] -= delta;
      j0 = j1;
    } while (p[j0] != 0);
    do {
      long long j1 = way[j0];
      p[j0] = p[j1];
      j0 = j1;
    } while (j0);
  }
  vector<long long> assignment(n + 1);
  for (long long j = 1; j <= m; ++j) assignment[p[j]] = j;
  long long ret = 0;
  for (long long i = 1; i <= n; ++i) {
    ret += cost[i][assignment[i]];
  }
  return ret;
}
long long arr[505][3];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<vector<long long>> cost;
  long long n;
  cin >> n;
  cost.resize(n + 1, vector<long long>(n + 1));
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    for (long long j = 1; j <= n; j++) {
      cost[i][j] = -max(0ll, arr[i][0] - min(j - 1, arr[i][2]) * arr[i][1]);
    }
  }
  cout << -hungarian(cost) << en;
  return 0;
}
