#include <bits/stdc++.h>
using namespace std;
const long long int LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 1111;
int N;
long long int A[SIZE], B[SIZE], k[SIZE];
long long int mtx[SIZE][SIZE];
long long int L[SIZE], R[SIZE], slack[SIZE];
int ml[SIZE], mr[SIZE], pre[SIZE];
bool vl[SIZE], vr[SIZE];
vector<int> ans;
bool check(int idx, queue<int> &q) {
  vl[idx] = true;
  if (ml[idx] != -1) {
    q.push(ml[idx]);
    vr[ml[idx]] = true;
    return true;
  }
  while (idx != -1) {
    ml[idx] = pre[idx];
    swap(idx, mr[ml[idx]]);
  }
  return false;
}
void BFS(int st, int n) {
  for (int i = 1; i <= n; i++) {
    slack[i] = LLINF;
    vl[i] = false;
    vr[i] = false;
  }
  queue<int> q;
  q.push(st);
  vr[st] = true;
  while (true) {
    int cost;
    while (!q.empty()) {
      int indx = q.front();
      q.pop();
      for (int i = 1; i <= n; i++) {
        int idx = i;
        cost = L[idx] + R[indx] - mtx[idx][indx];
        if (vl[idx] == false && cost <= slack[idx]) {
          pre[idx] = indx;
          if (cost != 0)
            slack[idx] = cost;
          else if (check(idx, q) == false)
            return;
        }
      }
    }
    cost = INF;
    for (int i = 1; i <= n; i++) {
      if (vl[i] == false && cost > slack[i]) cost = slack[i];
    }
    for (int i = 1; i <= n; i++) {
      if (vl[i] == true)
        L[i] += cost;
      else
        slack[i] -= cost;
      if (vr[i] == true) R[i] -= cost;
    }
    for (int i = 1; i <= n; i++) {
      if (vl[i] == false && slack[i] == 0 && check(i, q) == false) return;
    }
  }
}
long long int hungarian(int n) {
  for (int i = 1; i <= n; i++) {
    L[i] = 0;
    R[i] = 0;
    ml[i] = -1;
    mr[i] = -1;
    pre[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      L[i] = max(L[i], mtx[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) BFS(i, n);
  long long int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (mtx[i][ml[i]] != 0) {
      ret += mtx[i][ml[i]];
    }
  }
  return ret;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%lld %lld %lld", &A[i], &B[i], &k[i]);
  }
  memset(mtx, 0, sizeof(mtx));
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      long long int temp = A[i] - (B[i] * min(k[i], (long long int)j - 1));
      if (temp < 0) temp = 0;
      mtx[i][j] = temp;
    }
  }
  long long int ans = hungarian(N);
  printf("%lld\n", ans);
  return 0;
}
