#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 505;
int n;
long long f[N][N], ans = -INF;
struct node {
  long long a, b, c;
} p[N];
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
inline bool cmp(node x, node y) {
  if (x.b != y.b) return x.b > y.b;
  return x.c > y.c;
}
int main() {
  n = read();
  for (int i = (1), iend = (n); i <= iend; i++)
    p[i].a = read(), p[i].b = read(), p[i].c = read();
  sort(p + 1, p + n + 1, cmp);
  memset(f, -INF, sizeof(f));
  f[0][0] = 0;
  for (int i = (1), iend = (n); i <= iend; i++)
    for (int j = (0), jend = (n); j <= jend; j++) {
      f[i][j] = max(f[i - 1][j], f[i - 1][j] + p[i].a - p[i].b * p[i].c);
      if (j)
        f[i][j] = max(f[i][j], f[i - 1][j - 1] + p[i].a - (j - 1) * p[i].b);
    }
  for (int i = (0), iend = (n); i <= iend; i++) ans = max(ans, f[n][i]);
  printf("%lld", ans);
  return 0;
}
