#include <bits/stdc++.h>
using namespace std;
long long min_cost_match(vector<vector<long long>> adj) {
  int n = adj.size();
  int m = adj[0].size();
  vector<int> toright(n, -1), toleft(m, -1);
  vector<int> ofsleft(n, 0), ofsright(m, 0);
  for (int r = 0; r < (int)(n); r++) {
    vector<bool> left(n, false), right(m, false);
    vector<int> trace(m, -1), ptr(m, r);
    left[r] = true;
    for (;;) {
      long long d = 10000000000000LL;
      for (int j = 0; j < (int)(m); j++)
        if (!right[j])
          d = min(d, (-adj[ptr[j]][j] + ofsleft[ptr[j]] + ofsright[j]));
      for (int i = 0; i < (int)(n); i++)
        if (left[i]) ofsleft[i] -= d;
      for (int j = 0; j < (int)(m); j++)
        if (right[j]) ofsright[j] += d;
      int b = -1;
      for (int j = 0; j < (int)(m); j++)
        if (!right[j] && (-adj[ptr[j]][j] + ofsleft[ptr[j]] + ofsright[j]) == 0)
          b = j;
      trace[b] = ptr[b];
      int c = toleft[b];
      if (c < 0) {
        while (b >= 0) {
          int a = trace[b];
          int z = toright[a];
          toleft[b] = a;
          toright[a] = b;
          b = z;
        }
        break;
      }
      right[b] = left[c] = true;
      for (int j = 0; j < (int)(m); j++)
        if ((-adj[c][j] + ofsleft[c] + ofsright[j]) <
            (-adj[ptr[j]][j] + ofsleft[ptr[j]] + ofsright[j]))
          ptr[j] = c;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += adj[i][toright[i]];
  return ans;
}
long long hungarian(const vector<vector<long long>>& a) {
  int n = a.size(), p, q;
  vector<long long> fx(n, 10000000000000LL), fy(n, 0);
  vector<int> x(n, -1), y(n, -1);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) fx[i] = max(fx[i], a[i][j]);
  for (int i = 0; i < n;) {
    vector<int> t(n, -1), s(n + 1, i);
    for (p = q = 0; p <= q && x[i] < 0; p++)
      for (int k = s[p], j = 0; j < n && x[i] < 0; j++)
        if (fx[k] + fy[j] == a[k][j] && t[j] < 0) {
          s[++q] = y[j];
          t[j] = k;
          if (s[q] < 0)
            for (p = j; p >= 0; j = p) {
              y[j] = k = t[j];
              p = x[k];
              x[k] = j;
            }
        }
    if (x[i] < 0) {
      long long d = 10000000000000LL;
      for (int k = 0; k <= q; k++)
        for (int j = 0; j < n; j++)
          if (t[j] < 0) d = min(d, fx[s[k]] + fy[j] - a[s[k]][j]);
      for (int j = 0; j < n; j++) fy[j] += t[j] < 0 ? 0 : d;
      for (int k = 0; k <= q; k++) fx[s[k]] -= d;
    } else
      i++;
  }
  long long ret = 0;
  for (int i = 0; i < n; i++) ret += a[i][x[i]];
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N), b(N), k(N);
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i] >> k[i];
  vector<vector<long long>> mat(N);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      mat[i].emplace_back(max(0LL, a[i] - (long long)b[i] * min(k[i], j)));
  cout << min_cost_match(mat) << "\n";
  cout << flush;
  return 0;
}
