#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long a, b;
  int k;
} p[505];
int n;
long long f[505][505], ans;
bool cmp(Node a, Node b) { return a.b > b.b; }
int main() {
  ios::sync_with_stdio(false);
  memset(f, -127 / 3, sizeof(f));
  int i, j;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> p[i].a >> p[i].b >> p[i].k;
  sort(p + 1, p + n + 1, cmp);
  f[0][0] = 0;
  for (i = 1; i <= n; i++)
    for (j = 0; j <= n; j++) {
      f[i][j] = max(f[i - 1][j], f[i - 1][j] + p[i].a - p[i].b * p[i].k);
      if (j)
        f[i][j] = max(f[i][j], f[i - 1][j - 1] + p[i].a - p[i].b * (j - 1));
    }
  for (j = 0; j <= n; j++) ans = max(ans, f[n][j]);
  cout << ans;
  return 0;
}
