#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, k;
} p[505];
long long dp[505];
bool cmp(node x, node y) { return x.b > y.b; }
int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) {
    p[i].a = read();
    p[i].b = read();
    p[i].k = read();
  }
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    for (int j = n - 1; j >= 0; j--) {
      dp[j + 1] = max(dp[j + 1], dp[j] + p[i].a - 1LL * j * p[i].b);
      dp[j] = max(dp[j], dp[j] + p[i].a - 1LL * p[i].k * p[i].b);
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) ans = max(ans, dp[i]);
  printf("%I64d\n", ans);
  return 0;
}
