#include <bits/stdc++.h>
using namespace std;
const int N = 505;
struct node {
  long long a, b;
  int k;
} t[N];
int n;
long long f[N][N], ans;
int cmp(node A, node B) { return A.b > B.b; }
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    scanf("%lld%lld%d", &t[i].a, &t[i].b, &t[i].k);
  sort(t + 1, t + 1 + n, cmp);
  for (register int i = 1; i <= n; ++i) f[0][i] = -1e15;
  for (register int i = 1; i <= n; ++i) {
    long long ww = max(0LL, t[i].a - 1LL * t[i].k * t[i].b);
    f[i][0] = f[i - 1][0] + ww;
    for (register int j = 1; j <= i; ++j)
      f[i][j] = max(f[i - 1][j] + ww,
                    f[i - 1][j - 1] + t[i].a - 1LL * (j - 1) * t[i].b);
  }
  for (register int i = 0; i <= n; ++i) ans = max(ans, f[n][i]);
  printf("%lld\n", ans);
  return 0;
}
