#include <bits/stdc++.h>
using namespace std;
class loan {
 public:
  int a, b, k;
  bool operator<(const loan &t) const {
    if (b != t.b) return b > t.b;
    if (a != t.a) return a > t.a;
    return k < t.k;
  }
} p[510];
int n;
long long f[510][510];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &p[i].a, &p[i].b, &p[i].k);
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) fill(f[i], f[i] + n + 1, -1e18);
  f[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      if (i != j)
        f[i][j] = max(f[i][j],
                      f[i - 1][j] + max(-1ll * p[i].b * p[i].k + p[i].a, 0ll));
      else
        f[i][j] = max(-1ll * p[i].b * p[i].k + p[i].a, 0ll);
      if (j)
        f[i][j] =
            max(f[i][j], f[i - 1][j - 1] + p[i].a - 1ll * p[i].b * (j - 1));
    }
  }
  long long ans = -1e18;
  for (int i = 0; i <= n; i++) ans = max(ans, f[n][i]);
  printf("%lld\n", ans);
  return 0;
}
