#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, c = 1;
  char ch = ' ';
  while ((ch > '9' || ch < '0') && ch != '-') ch = getchar();
  while (ch == '-') c *= -1, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
  return x * c;
}
template <typename T>
inline void Max(T &a, T &b) {
  if (a < b) a = b;
}
template <typename T>
inline void Min(T &a, T &b) {
  if (a > b) a = b;
}
const double pi = (double)acos(-1.0);
const double eps = (double)1e-8;
const int INF = (int)0x3f3f3f3f;
const long long LINF = (long long)0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)5e2 + 10;
const int MAXM = (int)3e5 + 10;
int N;
int times;
long long a[MAXN], b[MAXN], k[MAXN];
int matchx[MAXN], matchy[MAXN];
long long matchx_val[MAXN], matchy_val[MAXN];
int visx[MAXN], visy[MAXN];
long long mp[MAXN][MAXN];
long long lx[MAXN], ly[MAXN], slack[MAXN];
int pre[MAXN];
bool DFS(int u) {
  visx[u] = times;
  for (int v = 1; v <= N; v++)
    if (visy[v] != times && (lx[u] + ly[v] - mp[u][v]) <= slack[v]) {
      long long val = mp[u][v];
      long long d = lx[u] + ly[v] - val;
      pre[v] = u;
      if (d == 0LL) {
        visy[v] = times;
        if (matchy[v] == -1 || DFS(matchy[v])) {
          matchx[u] = v;
          matchy[v] = u;
          matchx_val[u] = matchy_val[v] = val;
          return true;
        }
      } else if (slack[v] > d)
        slack[v] = d;
    }
  return false;
}
long long KM() {
  memset(lx, 0, sizeof(lx));
  memset(ly, 0, sizeof(ly));
  memset(matchx, -1, sizeof(matchx));
  memset(matchy, -1, sizeof(matchy));
  times = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      lx[i] = max(lx[i], mp[i][j]);
    }
  }
  int cnt = 0;
  for (int x = 1; x <= N; x++) {
    for (int y = 1; y <= N; y++) slack[y] = LINF;
    while (1) {
      ++times;
      if (DFS(x)) break;
      long long d = LINF;
      for (int y = 1; y <= N; y++) {
        if (visy[y] != times && d > slack[y]) d = slack[y];
      }
      for (int xx = 1; xx <= N; xx++) {
        if (visx[xx] == times) lx[xx] -= d;
      }
      for (int y = 1; y <= N; y++) {
        if (visy[y] == times)
          ly[y] += d;
        else
          slack[y] -= d;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++) ans += matchx_val[i];
  return ans;
}
void work() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%lld%lld%lld", &a[i], &b[i], &k[i]);
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      mp[i][j] = max(0LL, a[i] - b[i] * min(k[i], (long long)j - 1));
    }
  }
  printf("%lld\n", KM());
}
int main() {
  work();
  return 0;
}
