#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  int f = 0, c = getchar();
  x = 0;
  while (!isdigit(c)) f |= c == 45, c = getchar();
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (f) x = -x;
}
template <typename T, typename... Args>
inline void read(T &x, Args &...args) {
  read(x);
  read(args...);
}
namespace run {
const int maxn = 5e2 + 10;
struct node {
  long long x, y, z;
} a[maxn];
long long f[maxn][maxn];
int n;
long long ans;
inline bool cmp(node u, node v) { return u.y > v.y; }
inline int main() {
  read(n);
  for (register int i = 1; i <= n; ++i) read(a[i].x, a[i].y, a[i].z);
  sort(a + 1, a + 1 + n, cmp);
  for (register int i = 1; i <= n; ++i) f[0][i] = -1e18;
  for (register int i = 1; i <= n; ++i) {
    long long tmp = max(0ll, a[i].x - a[i].y * a[i].z);
    f[i][0] = f[i - 1][0] + tmp;
    for (register int j = 1; j <= i; ++j)
      f[i][j] = max(f[i - 1][j] + tmp,
                    f[i - 1][j - 1] + a[i].x - 1ll * (j - 1) * a[i].y);
  }
  for (register int i = 0; i <= n; ++i) ans = max(ans, f[n][i]);
  printf("%lld\n", ans);
  return 0;
}
}  // namespace run
int main() { return run ::main(); }
