#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505;
const long long INF = 0x3f3f3f3f3f3f3f3f;
long long love[MAXN][MAXN];
long long ex_girl[MAXN];
long long ex_boy[MAXN];
bool vis_girl[MAXN];
bool vis_boy[MAXN];
long long match[MAXN];
long long slack[MAXN];
int N;
bool dfs(int girl) {
  vis_girl[girl] = true;
  for (int boy = 0; boy < N; ++boy) {
    if (vis_boy[boy]) continue;
    long long gap = ex_girl[girl] + ex_boy[boy] - love[girl][boy];
    if (gap == 0) {
      vis_boy[boy] = true;
      if (match[boy] == -1 || dfs(match[boy])) {
        match[boy] = girl;
        return true;
      }
    } else {
      slack[boy] = min(slack[boy], gap);
    }
  }
  return false;
}
long long KM() {
  memset(match, -1, sizeof match);
  memset(ex_boy, 0, sizeof ex_boy);
  for (int i = 0; i < N; ++i) {
    ex_girl[i] = love[i][0];
    for (int j = 1; j < N; ++j) {
      ex_girl[i] = max(ex_girl[i], love[i][j]);
    }
  }
  for (int i = 0; i < N; ++i) {
    fill(slack, slack + N, INF);
    while (1) {
      memset(vis_girl, false, sizeof vis_girl);
      memset(vis_boy, false, sizeof vis_boy);
      if (dfs(i)) break;
      long long d = 0x3f3f3f3f3f3f3f3f;
      for (int j = 0; j < N; ++j)
        if (!vis_boy[j]) d = min(d, slack[j]);
      for (int j = 0; j < N; ++j) {
        if (vis_girl[j]) ex_girl[j] -= d;
        if (vis_boy[j])
          ex_boy[j] += d;
        else
          slack[j] -= d;
      }
    }
  }
  long long res = 0;
  for (int i = 0; i < N; ++i) res += love[match[i]][i];
  return res;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    long long a, b, k;
    scanf("%lld%lld%lld", &a, &b, &k);
    for (int j = 0; j < N; ++j) {
      love[i][j] = max(1LL * 0, a - b * min(k, 1LL * j));
    }
  }
  printf("%lld\n", KM());
  return 0;
}
