#include <bits/stdc++.h>
using namespace std;
long long dp[505][505];
long long n;
struct node {
  long long a;
  long long b;
  long long k;
} s[505];
bool cmp(node x1, node x2) { return x1.b > x2.b; }
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; ++i)
    scanf("%lld %lld %lld", &s[i].a, &s[i].b, &s[i].k);
  sort(s + 1, s + 1 + n, cmp);
  for (long long i = 1; i <= n; ++i) {
    long long tmp = max(0LL, s[i].a - s[i].k * s[i].b);
    dp[i][0] = dp[i - 1][0] + tmp;
    for (long long j = 1; j <= i; ++j)
      dp[i][j] =
          max(dp[i - 1][j] + tmp, dp[i - 1][j - 1] + s[i].a - (j - 1) * s[i].b);
  }
  long long ans = 0;
  for (long long i = 0; i <= n; ++i) ans = max(ans, dp[n][i]);
  printf("%lld\n", ans);
  return 0;
}
