#include <bits/stdc++.h>
using namespace std;
const int V = 2005;
const long long INF = 1e18;
struct Edge {
  int to, cap, rev;
  long long cost;
  Edge() {}
  Edge(int to, int cap, int rev, long long cost)
      : to(to), cap(cap), rev(rev), cost(cost) {}
};
vector<Edge> G[V];
long long h[V], dist[V];
int Prev[V], pree[V];
void add_edge(int from, int to, int cap, long long cost) {
  G[from].push_back((Edge){to, cap, (int)G[to].size(), cost});
  G[to].push_back((Edge){from, 0, (int)G[from].size() - 1, -cost});
}
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    que;
long long min_cost_flow(int s, int t, int f) {
  long long res = 0;
  memset(h, 0, sizeof(h));
  while (f) {
    for (int i = 0; i < V; i++) dist[i] = INF;
    dist[s] = 0;
    que.push(pair<long long, long long>(0, s));
    while (!que.empty()) {
      pair<long long, long long> p = que.top();
      que.pop();
      int v = p.second;
      if (dist[v] < p.first) continue;
      for (int i = 0; i < G[v].size(); i++) {
        Edge& e = G[v][i];
        if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          Prev[e.to] = v;
          pree[e.to] = i;
          que.push(pair<long long, long long>(dist[e.to], e.to));
        }
      }
    }
    if (dist[t] == INF) return res;
    for (int i = 0; i < V; i++) h[i] += dist[i];
    int d = f;
    for (int i = t; i != s; i = Prev[i]) {
      d = min(d, G[Prev[i]][pree[i]].cap);
    }
    f -= d;
    if (h[t] >= 0) return res;
    res += d * h[t];
    for (int i = t; i != s; i = Prev[i]) {
      Edge& e = G[Prev[i]][pree[i]];
      e.cap -= d, G[i][e.rev].cap += d;
    }
  }
  return res;
}
void solve() {
  int n;
  scanf("%d", &n);
  int s = 0, t = 2 * n + 1;
  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++) {
      add_edge(i, n + j, 1, -(a - 1LL * min(1LL * j - 1, k) * b));
    }
    add_edge(s, i, 1, 0);
    add_edge(n + i, t, 1, 0);
  }
  printf("%lld\n", -min_cost_flow(s, t, n));
}
int main() {
  solve();
  return 0;
}
