#include <bits/stdc++.h>
const long long inf = 1e16;
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f * x;
}
int n;
long long ans, d[505][505];
struct tmp {
  long long a, b, k;
  bool operator<(const tmp &o) const { return b > o.b; }
} a[505];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = tmp{read(), read(), read()};
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      d[i][j] = d[i - 1][j];
      if (j > 0)
        d[i][j] = max(d[i][j], d[i - 1][j - 1] + a[i].a - (j - 1) * a[i].b);
      d[i][j] = max(d[i][j], d[i - 1][j] + a[i].a - a[i].k * a[i].b);
    }
  }
  for (int i = 1; i <= n; i++) ans = max(ans, d[n][i]);
  return 0 * printf("%lld\n", ans);
}
