#include <bits/stdc++.h>
using namespace std;
namespace wm {
using T = long long;
const T INF = 1e18;
const int MAX = 505;
bool visited[MAX];
int P[MAX], way[MAX], match[MAX];
T U[MAX], V[MAX], minv[MAX], ara[MAX][MAX];
T hungarian(int n, int m, T mat[MAX][MAX], int flag) {
  memset(U, 0, sizeof(U)), memset(V, 0, sizeof(V)), memset(P, 0, sizeof(P)),
      memset(ara, 0, sizeof(ara)), memset(way, 0, sizeof(way));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ara[i][j] = flag * mat[i][j];
    }
  }
  if (n > m) m = n;
  int a, b, d;
  T r, w;
  for (int i = 1; i <= n; i++) {
    P[0] = i, b = 0;
    for (int j = 0; j <= m; j++) minv[j] = INF, visited[j] = false;
    do {
      visited[b] = true;
      a = P[b], d = 0, w = INF;
      for (int j = 1; j <= m; j++) {
        if (!visited[j]) {
          r = ara[a][j] - U[a] - V[j];
          if (r < minv[j]) minv[j] = r, way[j] = b;
          if (minv[j] < w) w = minv[j], d = j;
        }
      }
      for (int j = 0; j <= m; j++) {
        if (visited[j])
          U[P[j]] += w, V[j] -= w;
        else
          minv[j] -= w;
      }
      b = d;
    } while (P[b] != 0);
    do {
      d = way[b];
      P[b] = P[d], b = d;
    } while (b != 0);
  }
  for (int j = 1; j <= m; j++) match[P[j]] = j;
  return (flag == +1) ? -V[0] : V[0];
}
}  // namespace wm
int a[505], b[505], k[505];
long long mat[505][505];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &k[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      long long c = a[i] - min(k[i], j - 1) * 1LL * b[i];
      mat[i][j] = max(0LL, c);
    }
  }
  cout << wm::hungarian(n, n, mat, -1) << "\n";
  return 0;
}
