#include <bits/stdc++.h>
using namespace std;
const long long maxn = 505;
long long n, ans;
long long f[maxn][maxn];
struct cost {
  long long a, b, k;
} c[maxn];
inline long long cmp(cost x, cost y) { return x.b > y.b; }
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld%lld", &c[i].a, &c[i].b, &c[i].k);
  sort(c + 1, c + 1 + n, cmp);
  memset(f, -0x7fll, sizeof(f));
  f[0][0] = 0;
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= i; j++) {
      f[i][j] = f[i - 1][j] + max(0ll, c[i].a - c[i].b * c[i].k);
      if (j > 0)
        f[i][j] = max(f[i][j],
                      f[i - 1][j - 1] + c[i].a - c[i].b * min(c[i].k, j - 1));
    }
  for (long long i = 1; i <= n; i++) ans = max(ans, f[n][i]);
  printf("%lld\n", ans);
  return 0;
}
