#include <bits/stdc++.h>
using namespace std;
const int MAXN = 510;
const long long INF = 10000000000000000LL;
const long long inf = 5000000000000LL;
int n;
int nx, ny;
int times;
long long v[MAXN][MAXN];
long long ex[MAXN], ey[MAXN];
long long slack[MAXN];
int ux[MAXN], uy[MAXN], mx[MAXN], my[MAXN], pre[MAXN];
template <class T>
inline void freshmin(T &a, const T &b) {
  if (a > b) a = b;
}
void match(int y) {
  while (y) {
    my[y] = pre[y];
    swap(y, mx[pre[y]]);
  }
}
void bfs(int sx) {
  for (int y = 1; y <= ny; ++y) slack[y] = INF;
  queue<int> Q;
  Q.push(sx);
  ++times;
  while (1) {
    while (!Q.empty()) {
      int x = Q.front();
      Q.pop();
      ux[x] = times;
      long long gap;
      for (int y = 1; y <= ny; ++y)
        if (uy[y] != times && (gap = ex[x] + ey[y] - v[x][y]) <= slack[y]) {
          pre[y] = x;
          if (!gap) {
            uy[y] = times;
            if (!my[y])
              return match(y);
            else
              Q.push(my[y]);
          } else
            slack[y] = gap;
        }
    }
    long long d = INF;
    for (int y = 1; y <= ny; ++y)
      if (uy[y] != times) freshmin(d, slack[y]);
    for (int x = 1; x <= nx; ++x)
      if (ux[x] == times) ex[x] -= d;
    for (int y = 1; y <= ny; ++y)
      if (uy[y] == times)
        ey[y] += d;
      else
        slack[y] -= d;
    for (int y = 1; y <= ny; ++y)
      if (uy[y] != times && !slack[y]) {
        uy[y] = times;
        if (!my[y])
          return match(y);
        else
          Q.push(my[y]);
      }
  }
}
void KM() {
  for (int y = 1; y <= ny; ++y) {
    my[y] = 0;
    ey[y] = 0;
    uy[y] = 0;
  }
  for (int x = 1; x <= nx; ++x) {
    mx[x] = 0;
    ex[x] = *max_element(v[x] + 1, v[x] + ny + 1);
    ux[x] = 0;
  }
  for (int x = 1; x <= nx; ++x) bfs(x);
  long long ans = 0;
  for (int y = 1; y <= ny; ++y) ans += v[my[y]][y];
  cout << ans << endl;
}
int main() {
  scanf("%d", &n);
  for (long long x = 1; x <= n; x++) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    for (long long i = 1; i <= n; i++) {
      long long tm = i - 1;
      tm = min(c, tm);
      long long p = a - b * tm;
      if (p > 0) v[x][i] = p;
    }
  }
  nx = ny = n;
  KM();
}
