#include <bits/stdc++.h>
using namespace std;
namespace Hungary {
const long long inf = 1e18;
const int maxn = 505;
long long a[maxn][maxn];
long long p[2][maxn];
long long match[maxn];
bool used[maxn];
long long from[maxn];
long long mind[maxn];
long long n, m;
long long hungary(long long v) {
  used[v] = true;
  long long u = match[v];
  long long best = -1;
  for (long long i = 0; i < m + 1; i++) {
    if (used[i]) continue;
    long long nw = a[u][i] - p[0][u] - p[1][i];
    if (nw <= mind[i]) {
      mind[i] = nw;
      from[i] = v;
    }
    if (best == -1 || mind[best] > mind[i]) best = i;
  }
  v = best;
  long long delta = mind[best];
  for (long long i = 0; i < m + 1; i++) {
    if (used[i]) {
      p[1][i] -= delta;
      p[0][match[i]] += delta;
    } else
      mind[i] -= delta;
  }
  if (match[v] == -1) return v;
  return hungary(v);
}
void check() {
  long long edges = 0, res = 0;
  for (long long i = 0; i < m; i++)
    if (match[i] != -1) {
      ++edges;
      assert(p[0][match[i]] + p[1][i] == a[match[i]][i]);
      res += a[match[i]][i];
    } else
      assert(p[1][i] == 0);
  assert(res == -p[1][m]);
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) assert(p[0][i] + p[1][j] <= a[i][j]);
}
long long run() {
  for (long long i = 0; i < n; i++) p[0][i] = 0;
  for (long long i = 0; i < m + 1; i++) {
    p[1][i] = 0;
    match[i] = -1;
  }
  for (long long i = 0; i < n; i++) {
    match[m] = i;
    fill(used, used + m + 1, false);
    fill(mind, mind + m + 1, inf);
    fill(from, from + m + 1, -1);
    long long v = hungary(m);
    while (v != m) {
      long long w = from[v];
      match[v] = match[w];
      v = w;
    }
  }
  check();
  return -p[1][m];
}
}  // namespace Hungary
int n, a, b, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  Hungary::n = Hungary::m = n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> k;
    for (int j = 0; j < n; j++)
      Hungary::a[i][j] = -max(0ll, a - (long long)b * min(j, k));
  }
  cout << -Hungary::run() << '\n';
  return 0;
}
