#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const long long MAXN = 100010;
const long long INF = 1e17;
long long N;
long long a[MAXN + 1], b[MAXN + 1], len[MAXN + 1];
struct data {
  long long a, b, len;
} q[MAXN + 1];
bool cmp(data a, data b) { return a.b > b.b; }
long long f[510][510];
int main() {
  N = read();
  long long sum = 0;
  for (long long i = 1; i <= N; i++) {
    q[i].a = read(), q[i].b = read(), q[i].len = read();
    sum += q[i].a;
  }
  sort(q + 1, q + N + 1, cmp);
  for (long long i = 0; i <= N; i++)
    for (long long j = 0; j <= N; j++) f[i][j] = -INF;
  f[0][0] = 0;
  for (long long i = 1; i <= N; i++) {
    for (long long j = i - 1; j >= 0; j--) {
      for (long long k = i - 1 - j; k >= 0; k--) {
        if (f[j][k] == -INF) continue;
        f[j + 1][k] = max(f[j][k] + q[i].a - q[i].len * q[i].b, f[j + 1][k]);
        f[j][k + 1] = max(f[j][k] + q[i].a - k * q[i].b, f[j][k + 1]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= N; i++)
    for (long long j = 0; j <= N; j++) ans = max(ans, f[i][j]);
  printf("%lld\n", ans);
  return 0;
}
