#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int maxn = 505;
const int INF = 0x3f3f3f3f;
int nx, ny;
long long g[N][N];
long long a, b, k;
long long lx[N], ly[N];
int linker[N];
long long slack[N];
bool visx[N], visy[N];
bool DFS(int x) {
  visx[x] = true;
  for (int y = 1; y <= ny; y++) {
    if (visy[y]) continue;
    long long tmp = lx[x] + ly[y] - g[x][y];
    if (tmp == 0) {
      visy[y] = true;
      if (linker[y] == -1 || DFS(linker[y])) {
        linker[y] = x;
        return true;
      }
    } else if (slack[y] > tmp)
      slack[y] = tmp;
  }
  return false;
}
long long KM() {
  memset(linker, -1, sizeof(linker));
  memset(ly, 0, sizeof(ly));
  for (int i = 1; i <= nx; i++) {
    lx[i] = -INF;
    for (int j = 1; j <= ny; j++)
      if (g[i][j] > lx[i]) lx[i] = g[i][j];
  }
  for (int x = 1; x <= nx; x++) {
    for (int i = 1; i <= ny; i++) slack[i] = INF;
    while (true) {
      memset(visx, false, sizeof(visx));
      memset(visy, false, sizeof(visy));
      if (DFS(x)) break;
      long long d = INF;
      for (int i = 1; i <= ny; i++)
        if (!visy[i] && d > slack[i]) d = slack[i];
      for (int i = 1; i <= nx; i++)
        if (visx[i]) lx[i] -= d;
      for (int i = 1; i <= ny; i++) {
        if (visy[i])
          ly[i] += d;
        else
          slack[i] -= d;
      }
    }
  }
  long long res = 0;
  for (int i = 1; i <= ny; i++)
    if (linker[i] != -1) res += g[linker[i]][i];
  return res;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld%lld%lld", &a, &b, &k);
    for (int j = 1; j <= n; ++j)
      g[i][j] = max(a - b * min(k, 1LL * j - 1), 1LL * 0);
  }
  nx = ny = n;
  nx = ny = n;
  cout << KM();
  return 0;
}
