#include <bits/stdc++.h>
using namespace std;
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() {
  scanf("%d", &n);
  int i, j, k;
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d%I64d", &a[i].a, &a[i].b, &a[i].k);
  }
  sort(a + 1, a + 1 + n);
  for (i = 1; i <= n; i++) {
    for (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 (i = 1; i <= n; i++) ans = max(ans, d[n][i]);
  printf("%I64d\n", ans);
}
