#include <bits/stdc++.h>
using namespace std;
const int N = 505;
struct ky {
  int a, b, k;
  long long w;
  bool operator<(const ky& p) const { return b > p.b; }
} a[N];
inline long long Max(const long long p, const long long q) {
  return p > q ? p : q;
}
long long ans, f[N][N];
int n;
int main() {
  scanf("%d", &n);
  register int i, j;
  for (i = 1; i <= n; ++i)
    scanf("%d%d%d", &a[i].a, &a[i].b, &a[i].k),
        a[i].w = a[i].a - (0ll + a[i].b) * a[i].k;
  std::sort(a + 1, a + 1 + n);
  for (i = 1; i <= n; ++i)
    for (j = i; ~j; --j)
      f[i][j] = Max(f[i - 1][j], f[i - 1][j] + a[i].w),
      j ? f[i][j] = Max(f[i][j],
                        f[i - 1][j - 1] + a[i].a - (0ll + a[i].b) * (j - 1ll)),
      0 : 0, ans = Max(ans, f[i][j]);
  printf("%lld", ans);
  return 0;
}
