#include <bits/stdc++.h>
using namespace std;
const int iinf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const long long N = 500;
long long n;
long long a[N + 7], b[N + 7], k[N + 7], e[N + 7][N + 7], ans;
long long mb[N + 7], vb[N + 7], ka[N + 7], kb[N + 7], p[N + 7], c[N + 7];
long long qf, qb, q[N + 7];
void Bfs(long long u) {
  long long a, v = 0, vl = 0, d;
  for (long long i = 1; i <= n; i++) p[i] = 0, c[i] = linf;
  mb[v] = u;
  do {
    a = mb[v], d = linf, vb[v] = 1;
    for (long long b = 1; b <= n; b++)
      if (!vb[b]) {
        if (c[b] > ka[a] + kb[b] - e[a][b])
          c[b] = ka[a] + kb[b] - e[a][b], p[b] = v;
        if (c[b] < d) d = c[b], vl = b;
      }
    for (long long b = 0; b <= n; b++)
      if (vb[b])
        ka[mb[b]] -= d, kb[b] += d;
      else
        c[b] -= d;
    v = vl;
  } while (mb[v]);
  while (v) mb[v] = mb[p[v]], v = p[v];
}
long long KM() {
  for (long long i = 1; i <= n; i++) mb[i] = ka[i] = kb[i] = 0;
  for (long long a = 1; a <= n; a++) {
    for (long long b = 1; b <= n; b++) vb[b] = 0;
    Bfs(a);
  }
  long long res = 0;
  for (long long b = 1; b <= n; b++) res += e[mb[b]][b];
  return res;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = (1), I = (n + 1); i < I; i++) cin >> a[i] >> b[i] >> k[i];
  for (long long i = (1), I = (n + 1); i < I; i++)
    for (long long j = (1), I = (n + 1); j < I; j++)
      e[i][j] = max(a[i] - b[i] * min(k[i], 1ll * n - j), 0ll);
  cout << KM() << '\n';
  return 0;
}
