#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}
const int N = 500 + 10;
const int INF = 0x3f3f3f3f;
int n;
int a[N], b[N], k[N];
long long w[N][N];
long long minv[N], lu[N], lv[N];
int vis[N], p[N], way[N];
inline long long KM() {
  long long ans = 0;
  for (register int i = 1; i <= n; ++i) {
    p[0] = i;
    int j0 = 0;
    memset(minv, 0x3f, sizeof(minv));
    memset(vis, 0, sizeof(vis));
    do {
      vis[j0] = 1;
      int i0 = p[j0], j1;
      long long dlt = 2e18;
      for (register int j = 1; j <= n; ++j)
        if (!vis[j]) {
          long long now = w[i0][j] - lu[i0] - lv[j];
          if (now < minv[j]) minv[j] = now, way[j] = j0;
          if (minv[j] < dlt) dlt = minv[j], j1 = j;
        }
      for (register int j = 0; j <= n; ++j) {
        if (vis[j])
          lu[p[j]] += dlt, lv[j] -= dlt;
        else
          minv[j] -= dlt;
      }
      j0 = j1;
    } while (p[j0]);
    do {
      int j1 = way[j0];
      p[j0] = p[j1];
      j0 = j1;
    } while (j0);
    ans = max(ans, lv[0]);
  }
  return ans;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; ++i)
    a[i] = read(), b[i] = read(), k[i] = read();
  for (register int i = 1; i <= n; ++i)
    for (register int j = 1; j <= n; ++j)
      w[i][j] = -a[j] + 1ll * b[j] * min(i - 1, k[j]);
  printf("%I64d\n", KM());
  return 0;
}
