#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cap;
  long long cost;
  int rev;
};
const long long inf = 1e18 + 10;
const int maxn = 1e3 + 10;
vector<edge> g[maxn];
long long dist[maxn], h[maxn];
int prevv[maxn], preve[maxn];
int m = 0;
void add_edge(int u, int v, int cap, long long cost) {
  g[u].push_back((edge){v, cap, cost, (int)g[v].size()});
  g[v].push_back((edge){u, 0, -cost, (int)g[u].size() - 1});
}
long long min_cost_flow(int s, int t, int f) {
  long long res = 0;
  while (f > 0) {
    priority_queue<pair<int, int>, vector<pair<int, int> >,
                   greater<pair<int, int> > >
        Q;
    for (int i = 0; i < m; i++) dist[i] = inf;
    dist[s] = 0;
    Q.push(make_pair(0, s));
    while (!Q.empty()) {
      pair<int, int> p = Q.top();
      Q.pop();
      int x = p.second;
      if (dist[x] < p.first) continue;
      for (int i = 0; i < (int)g[x].size(); i++) {
        edge &e = g[x][i];
        if (e.cap > 0 && dist[e.to] > dist[x] + e.cost + h[x] - h[e.to]) {
          dist[e.to] = dist[x] + e.cost + h[x] - h[e.to];
          prevv[e.to] = x;
          preve[e.to] = i;
          Q.push(make_pair(dist[e.to], e.to));
        }
      }
    }
    if (dist[t] == inf) return res;
    for (int i = 0; i < m; i++) h[i] += dist[i];
    int d = f;
    for (int x = t; x != s; x = prevv[x]) d = min(d, g[prevv[x]][preve[x]].cap);
    f -= d;
    res += 1ll * d * h[t];
    if (h[t] == 0) return res;
    for (int x = t; x != s; x = prevv[x]) {
      edge &e = g[prevv[x]][preve[x]];
      e.cap -= d;
      g[x][e.rev].cap += d;
    }
  }
  return res;
}
int n;
int main() {
  cin >> n;
  int s = 2 * n, t = s + 1;
  m = t + 1;
  for (int i = 0; i < n; i++) add_edge(s, i, 1, 0);
  for (int i = 0; i < n; i++) add_edge(n + i, t, 1, 0);
  for (int i = 0; i < n; i++) {
    long long a, b;
    int k;
    cin >> a >> b >> k;
    for (int j = 0; j < min(k, n); j++) {
      add_edge(i, j + n, 1, -a);
      a -= b;
    }
    for (int j = k; j < n; j++) {
      add_edge(i, j + n, 1, -a);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long val = -min_cost_flow(s, t, 1);
    if (val <= 0) break;
    ans += val;
  }
  cout << ans << endl;
  return 0;
}
