#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9 + 7;
constexpr long long INFL = 1e18;
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <typename Type>
Type hungarian(vector<vector<Type>> w, const Type INF) {
  int n = w.size();
  int m = (w.empty() ? 0 : w[0].size());
  if (n > m) {
    vector<vector<Type>> new_w(m, vector<Type>(n));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) new_w[j][i] = w[i][j];
    w = new_w;
    swap(n, m);
  }
  vector<Type> L(n + 1), R(m + 1);
  vector<int> p(m + 1), way(m + 1);
  for (int i = 1; i <= n; i++) {
    p[0] = i;
    int j0 = 0;
    vector<Type> minv(m + 1, INF);
    vector<bool> used(m + 1);
    do {
      used[j0] = true;
      int i0 = p[j0], j1;
      Type delta = INF;
      for (int j = 1; j <= m; j++)
        if (not used[j]) {
          Type cur = w[i0 - 1][j - 1] - L[i0] - R[j];
          if (cur < minv[j]) minv[j] = cur, way[j] = j0;
          if (minv[j] < delta) delta = minv[j], j1 = j;
        }
      for (int j = 0; j <= m; j++)
        if (used[j])
          L[p[j]] += delta, R[j] -= delta;
        else
          minv[j] -= delta;
      j0 = j1;
    } while (p[j0] != 0);
    do {
      int j1 = way[j0];
      p[j0] = p[j1];
      j0 = j1;
    } while (j0);
  }
  return -R[0];
}
constexpr int maxn = 505;
int n;
long long A[maxn], B[maxn], K[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  vector<vector<long long>> M(n, vector<long long>(n));
  for (int i = 0; i < n; i++) {
    cin >> A[i] >> B[i] >> K[i];
    for (int j = 0; j < n; j++)
      M[i][j] = -max(A[i] - B[i] * min(K[i], (long long)j), 0LL);
  }
  cout << -hungarian(M, INFL);
}
