#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
long long n;
long long a[505], b[505], k[505];
long long w[505][505];
long long km(long long n, long long m) {
  vector<int> u(n + 1), v(m + 1), p(m + 1), way(m + 1);
  for (long long i = 1; i <= n; i++) {
    p[0] = i;
    long long j0 = 0;
    vector<int> minv(m + 1, 1000000000);
    vector<char> used(m + 1, false);
    do {
      used[j0] = true;
      long long i0 = p[j0], delta = 1000000000, j1 = 0;
      for (long long j = 1; j <= m; ++j)
        if (!used[j]) {
          long long cur = w[i0][j] - u[i0] - v[j];
          if (cur < minv[j]) minv[j] = cur, way[j] = j0;
          if (minv[j] < delta) delta = minv[j], j1 = j;
        }
      for (long long j = 0; j <= m; ++j)
        if (used[j])
          u[p[j]] += delta, v[j] -= delta;
        else
          minv[j] -= delta;
      j0 = j1;
    } while (p[j0] != 0);
    do {
      long long j1 = way[j0];
      p[j0] = p[j1];
      j0 = j1;
    } while (j0);
  }
  long long res = 0;
  for (long long i = 1; i <= m; i++) res += w[p[i]][i];
  return -res;
}
int main() {
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) scanf("%lld%lld%lld", &a[i], &b[i], &k[i]);
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      w[i + 1][j + 1] = -(max(0LL, a[j] - min(i, k[j]) * b[j]));
  printf("%lld\n", km(n, n));
  return 0;
}
