#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
#pragma GCC target("avx,avx2")
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const long long N = 505;
long long f[N][N], n;
struct node {
  long long x, y, k;
  inline bool operator<(const node &nt) const { return y > nt.y; }
} a[N];
signed main() {
  read(n);
  for (long long i = 1; i <= n; i++) read(a[i].x, a[i].y, a[i].k);
  sort(a + 1, a + 1 + n);
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= i; j++) {
      f[i][j] = f[i - 1][j] + max(a[i].x - a[i].y * a[i].k, 0ll);
      if (j)
        f[i][j] = max(f[i][j], f[i - 1][j - 1] + a[i].x - a[i].y * (j - 1));
    }
  write(*max_element(f[n], f[n] + 1 + n));
}
