#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e2 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
struct KM {
  const long long inf = 1ll << 60;
  long long G[maxn][maxn], hl[maxn], hr[maxn], dt[maxn];
  int fl[maxn], fr[maxn], vl[maxn], vr[maxn], pre[maxn], q[maxn], ql, qr, n;
  void init(int nl, int nr) {
    n = max(nl, nr);
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) G[i][j] = 0;
    }
  }
  void add(int u, int v, long long w) { G[u][v] = max(G[u][v], w); }
  int check(int i) {
    if (vl[i] = 1, fl[i]) return q[qr++] = fl[i], vr[fl[i]] = 1;
    while (i) fl[i] = pre[i], swap(i, fr[fl[i]]);
    return 0;
  }
  void bfs(int s) {
    for (int i = 1; i <= n; ++i) vl[i] = vr[i] = 0, dt[i] = inf;
    ql = qr = 0, q[qr++] = s, vr[s] = 1;
    while (1) {
      while (ql < qr) {
        for (int i = 1, j = q[ql++]; i <= n; ++i) {
          long long d = hl[i] + hr[j] - G[i][j];
          if (vl[i] || dt[i] < d) continue;
          pre[i] = j;
          if (d)
            dt[i] = d;
          else if (!check(i))
            return;
        }
      }
      long long d = inf;
      for (int i = 1; i <= n; ++i)
        if (!vl[i] && d > dt[i]) d = dt[i];
      for (int i = 1; i <= n; ++i) {
        if (vl[i])
          hl[i] += d;
        else
          dt[i] -= d;
        if (vr[i]) hr[i] -= d;
      }
      for (int i = 1; i <= n; ++i) {
        if (!vl[i] && !dt[i] && !check(i)) return;
      }
    }
  }
  long long solve() {
    for (int i = 1; i <= n; ++i) fl[i] = fr[i] = hr[i] = 0;
    for (int i = 1; i <= n; ++i) hl[i] = *max_element(G[i] + 1, G[i] + 1 + n);
    for (int i = 1; i <= n; ++i) bfs(i);
    long long ret = 0;
    for (int i = 1; i <= n; ++i)
      if (G[i][fl[i]])
        ret += G[i][fl[i]];
      else
        fl[i] = fr[i] = 0;
    return ret;
  }
} km;
int n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  km.init(n, n);
  for (int i = 1; i <= n; ++i) {
    long long a, b, k;
    cin >> a >> b >> k;
    km.add(i, 1, a);
    for (int j = 1; j < n; ++j) {
      if (j <= k) a -= b;
      km.add(i, j + 1, a);
    }
  }
  long long ret = km.solve();
  cout << ret << endl;
  return 0;
}
