#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX / 2;
class MinCostMaxFlow {
 public:
  MinCostMaxFlow(int _n = 0, int _s = 0, int _t = 0)
      : n(_n), s(_s), t(_t), graph(n), dis(n, INF), pre(n, -1) {}
  void addEdge(int u, int v, int cap, int flow, long long cost) {
    graph[u].push_back(edges.size());
    edges.emplace_back(u, v, cap, flow, cost);
    graph[v].push_back(edges.size());
    edges.emplace_back(v, u, 0, 0, -cost);
  }
  bool bellmanFord() {
    vector<int> cur;
    cur.push_back(s);
    dis[s] = 0;
    pre[s] = -1;
    vector<int> rnds(n, -1);
    rnds[s] = 0;
    vector<int> nxt;
    for (int i = 0; i < n; ++i) {
      nxt.clear();
      for (auto u : cur) {
        for (auto e : graph[u]) {
          int v = edges[e].to;
          long long cost = edges[e].cost;
          if (edges[e].rem() > 0 && dis[v] > dis[u] + cost) {
            dis[v] = dis[u] + cost;
            pre[v] = e;
            if (rnds[v] != i) {
              rnds[v] = i;
              nxt.push_back(v);
            }
          }
        }
      }
      swap(cur, nxt);
    }
    return dis[t] != INF;
  }
  void reduceCost() {
    for (auto& ed : edges) {
      int u = ed.from;
      int v = ed.to;
      ed.cost += dis[u] - dis[v];
    }
  }
  bool dijkstra(int s, int t) {
    dis.assign(n, INF);
    dis[s] = 0;
    pre[s] = -1;
    priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                   greater<pair<long long, int>>>
        pq;
    pq.emplace(0, s);
    while (!pq.empty()) {
      long long d = pq.top().first;
      int u = pq.top().second;
      pq.pop();
      if (d > dis[u]) {
        continue;
      }
      for (auto e : graph[u]) {
        int v = edges[e].to;
        long long w = edges[e].cost;
        if (edges[e].rem() > 0 && dis[v] > d + w) {
          dis[v] = d + w;
          pre[v] = e;
          pq.emplace(dis[v], v);
        }
      }
    }
    return dis[t] != INF;
  }
  pair<long long, long long> minCostMaxFlow() {
    long long flow = 0;
    long long cost = 0;
    long long reduceSum = 0;
    if (!bellmanFord()) {
      return {0, 0};
    }
    do {
      reduceCost();
      reduceSum += dis[t];
      long long inc = INF;
      int v = t;
      while (v != s) {
        int e = pre[v];
        inc = min(inc, edges[e].rem());
        v = edges[e].from;
      }
      assert(inc != INF && inc > 0);
      v = t;
      while (v != s) {
        int e = pre[v];
        edges[e].aug(inc);
        edges[e ^ 1].aug(-inc);
        v = edges[e].from;
      }
      flow += inc;
      cost += reduceSum * inc;
    } while (dijkstra(s, t));
    return {flow, cost};
  }

 private:
  struct Edge {
   public:
    Edge(int u = 0, int v = 0, int cp = 0, int f = 0, long long ct = 0)
        : from(u), to(v), cap(cp), flow(f), cost(ct) {}
    long long rem() { return cap - flow; }
    void aug(long long inc) { flow += inc; }
    int from;
    int to;
    int cap;
    int flow;
    long long cost;
  };
  int n;
  int s;
  int t;
  vector<Edge> edges;
  vector<vector<int>> graph;
  vector<long long> dis;
  vector<int> pre;
};
class Solution {
 public:
  long long maximize(vector<vector<int>>& pv) {
    int n = pv.size();
    int s = n + n + 1;
    int t = s + 1;
    MinCostMaxFlow mf(t + 1, s, t);
    for (int i = 0; i < n; ++i) {
      mf.addEdge(s, i, 1, 0, 0);
    }
    for (int i = 0; i < n; ++i) {
      mf.addEdge(n + i, t, 1, 0, 0);
    }
    for (int i = 0; i < n; ++i) {
      long long a = pv[i][0];
      long long b = pv[i][1];
      long long k = pv[i][2];
      for (int j = 0; j < n; ++j) {
        long long cost = -max(a - min((long long)j, k) * b, 0LL);
        mf.addEdge(i, n + j, 1, 0, cost);
      }
    }
    long long res = -mf.minCostMaxFlow().second;
    return res;
  }
};
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution sol;
  int n;
  cin >> n;
  vector<vector<int>> pv;
  pv.reserve(n);
  for (int i = 0; i < n; ++i) {
    int a, b, k;
    cin >> a >> b >> k;
    pv.emplace_back(vector<int>{a, b, k});
  }
  cout << sol.maximize(pv) << "\n";
  return 0;
}
