#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
const int N = 1005;
const long long INF = 0x3f3f3f3f3f3f3f3f;
template <class T>
bool read(T& x) {
  char c;
  while (!isdigit(c = getchar()) && c != '-' && c != EOF)
    ;
  if (c == EOF) return false;
  T flag = 1;
  if (c == '-') {
    flag = -1;
    x = 0;
  } else
    x = c - '0';
  while (isdigit(c = getchar())) x = x * 10 + c - '0';
  x *= flag;
  return true;
}
template <class T, class... R>
bool read(T& a, R&... b) {
  if (!read(a)) return false;
  return read(b...);
}
mt19937 gen(steady_clock::now().time_since_epoch().count());
long long w[N][N];
int linker[N];
int pre[N];
long long lx[N], ly[N], slack[N];
bool vis_y[N];
void km_bfs(int u, int n) {
  for (int i = 0; i <= n; i++) {
    pre[i] = 0;
    slack[i] = INF;
    vis_y[i] = false;
  }
  int y = 0, yy = 0;
  linker[y] = u;
  while (true) {
    int x = linker[y];
    long long d = INF;
    vis_y[y] = true;
    for (int i = 1; i <= n; i++) {
      if (!vis_y[i]) {
        if (slack[i] > lx[x] + ly[i] - w[x][i]) {
          slack[i] = lx[x] + ly[i] - w[x][i];
          pre[i] = y;
        }
        if (slack[i] < d) {
          d = slack[i];
          yy = i;
        }
      }
    }
    for (int i = 0; i <= n; i++) {
      if (vis_y[i]) {
        lx[linker[i]] -= d;
        ly[i] += d;
      } else
        slack[i] -= d;
    }
    y = yy;
    if (!linker[y]) break;
  }
  while (y) {
    linker[y] = linker[pre[y]];
    y = pre[y];
  }
}
long long km(int n) {
  for (int i = 0; i <= n; i++) linker[i] = lx[i] = ly[i] = 0;
  for (int i = 1; i <= n; i++) km_bfs(i, n);
  long long r = 0;
  for (int i = 1; i <= n; i++) r += w[linker[i]][i];
  return r;
}
int a[N], b[N], k[N];
int main() {
  time_point<steady_clock> start = steady_clock::now();
  int n;
  read(n);
  for (int i = 0; i < n; i++) read(a[i], b[i], k[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      w[i + 1][j + 1] = a[j] - min(i, k[j]) * 1LL * b[j];
  printf("%lld\n", km(2 * n));
  cerr << endl
       << "------------------------------" << endl
       << "Time: "
       << duration<double, milli>(steady_clock::now() - start).count() << " ms."
       << endl;
  return 0;
}
