#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const int N = 500;
const long long MIN = (long long)N * (-INF);
int n;
int x[N], y[N], k[N], prev[N + 2], p[N + 2];
bool usd[N + 2];
long long a[N + 1][N + 2], u[N + 1], v[N + 1], mn[N + 2];
void hungarian(int n, int m) {
  for (int i = 1; i <= n; ++i) {
    int j0 = 0;
    memset(mn, 0x3f, 8 * (m + 1));
    memset(usd, 0, m + 1);
    p[0] = i;
    do {
      usd[j0] = true;
      int i0 = p[j0];
      int ind = 0;
      for (int j = 1; j <= m; ++j)
        if (!usd[j]) {
          long long val = a[i0][j] - u[i0] - v[j];
          if (val < mn[j]) {
            mn[j] = val;
            prev[j] = j0;
          }
          if (mn[ind] > mn[j]) ind = j;
        }
      long long d = mn[ind];
      if (d) {
        for (int j = 0; j <= m; ++j) {
          if (usd[j]) {
            v[j] -= d;
            u[p[j]] += d;
          } else
            mn[j] -= d;
        }
      }
      j0 = ind;
    } while (p[j0]);
    do {
      p[j0] = p[prev[j0]];
      j0 = prev[j0];
    } while (j0);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d%d%d", x + i, y + i, k + i);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      a[i + 1][j + 1] =
          std::min((long long)std::min(i, k[j]) * y[j] - x[j], (long long)0);
  std::fill(u + 1, u + n + 1, MIN);
  std::fill(v + 1, v + n + 1, MIN);
  v[0] = -2 * n * MIN;
  hungarian(n, n);
  printf("%lld\n", v[0]);
  return 0;
}
