#include <bits/stdc++.h>
using namespace std;
const int maxn = 50015;
const int INF = 0x3f3f3f3f;
struct edge {
  int to, capacity, rev;
  long long cost;
  edge() {}
  edge(int to, int _capacity, long long _cost, int _rev)
      : to(to), capacity(_capacity), cost(_cost), rev(_rev) {}
};
struct Min_Cost_Max_Flow {
  int V, PreV[maxn + 5], PreE[maxn + 5];
  long long dis[maxn + 5], H[maxn + 5];
  vector<edge> G[maxn + 5];
  void Init(int n) {
    V = n;
    for (int i = 0; i <= V; ++i) G[i].clear();
  }
  void Add_Edge(int from, int to, int cap, long long cost) {
    G[from].emplace_back(edge(to, cap, cost, G[to].size()));
    G[to].emplace_back(edge(from, 0, -cost, G[from].size() - 1));
  }
  long long Max_cost_max_flow(int s, int t, int f, int& flow) {
    long long res = 0;
    fill(H, H + 1 + V, 0);
    while (f) {
      priority_queue<pair<int, int>> q;
      fill(dis, dis + 1 + V, -INF);
      dis[s] = 0;
      q.push(pair<int, int>(0, s));
      while (!q.empty()) {
        pair<int, int> now = q.top();
        q.pop();
        int v = now.second;
        if (dis[v] > now.first) continue;
        for (int i = 0; i < G[v].size(); ++i) {
          edge& e = G[v][i];
          if (e.capacity > 0 && dis[e.to] < dis[v] + e.cost + H[v] - H[e.to]) {
            dis[e.to] = dis[v] + e.cost + H[v] - H[e.to];
            PreV[e.to] = v;
            PreE[e.to] = i;
            q.push(pair<int, int>(dis[e.to], e.to));
          }
        }
      }
      if (dis[t] == -INF) break;
      for (int i = 0; i <= V; ++i) H[i] += dis[i];
      int d = f;
      for (int v = t; v != s; v = PreV[v])
        d = min(d, G[PreV[v]][PreE[v]].capacity);
      f -= d;
      flow += d;
      if (H[t] < 0) return res;
      res += d * H[t];
      for (int v = t; v != s; v = PreV[v]) {
        edge& e = G[PreV[v]][PreE[v]];
        e.capacity -= d;
        G[v][e.rev].capacity += d;
      }
    }
    return res;
  }
} fuck;
int main() {
  int n;
  cin >> n;
  fuck.Init(n + n + 2);
  int a, b;
  int s = 0, t = n + n + 1;
  long long k;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%lld", &a, &b, &k);
    for (int j = 1; j <= n; j++) {
      fuck.Add_Edge(i, n + j, 1, (a - 1LL * min(1LL * j - 1, k) * b));
    }
    fuck.Add_Edge(s, i, 1, 0);
    fuck.Add_Edge(i + n, t, 1, 0);
  }
  int tmp;
  long long ans = fuck.Max_cost_max_flow(s, t, INF, tmp);
  printf("%lld\n", ans);
  return 0;
}
