#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n;
struct edge {
  long long a, b, k;
} c[510];
bool cmp(edge x, edge y) { return x.b > y.b; }
long long f[510][510];
int i, j, k;
int main() {
  n = read();
  for (i = 1; i <= n; i++) {
    c[i].a = read();
    c[i].b = read();
    c[i].k = read();
  }
  sort(c + 1, c + 1 + n, cmp);
  for (i = 1; i <= n; i++)
    for (j = 0; j <= n; j++) {
      f[i][j] = f[i - 1][j] + max(0ll, c[i].a - c[i].b * c[i].k);
      if (j)
        f[i][j] = max(f[i][j], f[i - 1][j - 1] + c[i].a - c[i].b * (j - 1));
    }
  long long ans = 0;
  for (i = 0; i <= n; i++) ans = max(ans, f[n][i]);
  cout << ans << endl;
}
