#include <bits/stdc++.h>
using namespace std;
struct aaa {
  long long x, y, w;
} a[100010];
long long n, i, j, ans, f[1010][1010];
bool cmp(aaa a, aaa b) { return a.x > b.x; }
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld%lld%lld", &a[i].w, &a[i].x, &a[i].y);
  sort(a + 1, a + n + 1, cmp);
  memset(f, 172, sizeof(f));
  f[0][0] = 0;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < i; j++) {
      f[i][j] = max(f[i][j], f[i - 1][j]);
      f[i][j] = max(f[i][j], f[i - 1][j] + a[i].w - a[i].x * a[i].y);
      if (a[i].y >= j + 1)
        f[i][j + 1] = max(f[i][j + 1], f[i - 1][j] + a[i].w - a[i].x * j);
    }
  }
  for (i = 0; i <= n; i++) ans = max(ans, f[n][i]);
  printf("%lld", ans);
}
