#include <bits/stdc++.h>
using namespace std;
const int N = 501;
const long long inf = LLONG_MAX;
vector<int> g[N];
int lnk[N], pre[N];
bool vis[N];
long long a[N], b[N], w[N][N], sl[N];
long long match(int nl, int nr) {
  nr = max(nl, nr);
  fill_n(g + 1, nl, vector<int>());
  fill_n(lnk + 1, nr, 0);
  for (int i = 1; i <= nl; ++i) a[i] = *max_element(w[i] + 1, w[i] + nr + 1);
  fill_n(b + 1, nr, 0);
  for (int i = 1, j, u, vt; i <= nl; ++i) {
    fill_n(vis + 1, nr, 0);
    fill_n(sl, nr + 1, inf);
    lnk[0] = i;
    for (j = 0; u = lnk[j]; j = vt) {
      long long d = inf;
      vis[j] = 1;
      for (int v = 1; v <= nr; ++v) {
        long long t = a[u] + b[v] - w[u][v];
        if (vis[v]) continue;
        if (sl[v] > t) sl[v] = t, pre[v] = j;
        if (sl[v] < d) d = sl[v], vt = v;
      }
      for (int v = 0; v <= nr; ++v) {
        if (vis[v])
          a[lnk[v]] -= d, b[v] += d;
        else
          sl[v] -= d;
      }
    }
    for (; j; j = pre[j]) lnk[j] = lnk[pre[j]];
  }
  long long res = 0;
  for (int i = 1; i <= nl; ++i) res += a[i] + b[i];
  return res;
}
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    long long a, b, k;
    scanf("%lld %lld %lld", &a, &b, &k);
    for (int j = 1; j <= n; ++j)
      w[i][j] = max(0ll, a - b * (min((long long)j, k + 1) - 1));
  }
  printf("%lld\n", match(n, n));
  return 0;
}
