#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = (int)1e9 + 7;
const int N = 510;
int n;
int val[N][N];
long long lx[N], ly[N], slack[N];
int linky[N];
long long pre[N];
bool vis[N], visx[N], visy[N];
void bfs(int k) {
  long long px, py = 0, yy = 0, d;
  memset(pre, 0, sizeof(long long) * (n + 2));
  memset(slack, inf, sizeof(long long) * (n + 2));
  linky[py] = k;
  do {
    px = linky[py], d = INF, vis[py] = 1;
    for (int i = 1; i <= n; i++)
      if (!vis[i]) {
        if (slack[i] > lx[px] + ly[i] - val[px][i])
          slack[i] = lx[px] + ly[i] - val[px][i], pre[i] = py;
        if (slack[i] < d) d = slack[i], yy = i;
      }
    for (int i = 0; i <= n; i++)
      if (vis[i])
        lx[linky[i]] -= d, ly[i] += d;
      else
        slack[i] -= d;
    py = yy;
  } while (linky[py]);
  while (py) linky[py] = linky[pre[py]], py = pre[py];
}
void KM() {
  memset(lx, 0, sizeof lx);
  memset(ly, 0, sizeof ly);
  memset(linky, 0, sizeof(int) * (n + 2));
  for (int i = 1; i <= n; i++) memset(vis, 0, sizeof(bool) * (n + 2)), bfs(i);
}
void input() {
  scanf("%d", &n);
  long long a, b, k;
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d%I64d%I64d", &a, &b, &k);
    for (long long j = 0; j < n; ++j) {
      val[i][j + 1] = max(0ll, a - min(j, k) * b);
    }
  }
}
int main() {
  input();
  KM();
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += lx[i] + ly[i];
  printf("%lld\n", ans);
  return 0;
}
