#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int n;
long long a[510][510];
int p[510];
long long q1[510];
long long q2[510];
int f1[510];
int f2[510];
long long g[510];
bool dfs(int x) {
  int i;
  long long gap;
  f1[x] = 1;
  for (i = 1; i <= n; i++) {
    if (f2[i] == 0) {
      gap = q1[x] + q2[i] - a[x][i];
      if (gap == 0) {
        f2[i] = 1;
        if (p[i] == 0 || dfs(p[i])) {
          p[i] = x;
          return true;
        }
      } else
        g[i] = min(g[i], gap);
    }
  }
  return false;
}
long long km() {
  int i, j;
  long long k, ans;
  for (i = 1; i <= n; i++) {
    p[i] = 0;
    q2[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    q1[i] = a[i][1];
    for (j = 2; j <= n; j++) q1[i] = max(q1[i], a[i][j]);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) g[j] = mod * mod;
    while (1) {
      for (j = 1; j <= n; j++) {
        f1[j] = 0;
        f2[j] = 0;
      }
      if (dfs(i)) break;
      k = mod * mod;
      for (j = 1; j <= n; j++)
        if (f2[j] == 0) k = min(k, g[j]);
      for (j = 1; j <= n; j++) {
        if (f1[j]) q1[j] -= k;
        if (f2[j])
          q2[j] += k;
        else
          g[j] -= k;
      }
    }
  }
  ans = 0;
  for (i = 1; i <= n; i++) ans += a[p[i]][i];
  return ans;
}
int main() {
  int i, j;
  long long a1, b1, c1;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a1 >> b1 >> c1;
    for (j = 1; j <= n; j++)
      a[i][j] = max(0LL, a1 - b1 * min((long long)j - 1, c1));
  }
  cout << km() << "\n";
  return 0;
}
