#include <bits/stdc++.h>
using namespace std;
const long long finf = -1e15;
struct pp {
  long long x, y, z;
} a[505];
long long f[505][505], ans = 0, n;
bool cmp(pp o, pp p) { return o.y > p.y; }
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld%lld", &a[i].x, &a[i].y, &a[i].z);
  sort(a + 1, a + n + 1, cmp);
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= i; j++) {
      f[i][j] = f[i - 1][j];
      if (j > 0)
        f[i][j] = max(f[i][j], f[i - 1][j - 1] + a[i].x - a[i].y * (j - 1));
      f[i][j] = max(f[i][j], f[i - 1][j] + a[i].x - a[i].y * a[i].z);
      ans = max(ans, f[i][j]);
    }
  cout << ans << endl;
  return 0;
}
