#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 3;
int n, id[N];
long long a[N], b[N], k[N], f[N][N];
inline bool cmp(int A, int B) { return b[A] > b[B]; }
int main() {
  scanf("%d", &n);
  for (register int i = (1); i <= (n); ++i)
    scanf("%lld%lld%lld", a + i, b + i, k + i), id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  for (register int i = (1); i <= (n); ++i)
    for (register int j = (0); j <= (i); ++j) {
      int p = id[i];
      f[i][j] = max({f[i - 1][j], f[i - 1][j] + a[p] - k[p] * b[p],
                     (j) ? (f[i - 1][j - 1] + a[p] -
                            b[p] * min(k[p], (long long)(j - 1ll)))
                         : 0});
    }
  long long res = 0;
  for (register int i = (0); i <= (n); ++i) res = max(res, f[n][i]);
  printf("%lld\n", res);
  return 0;
}
