#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long val, cost, num;
};
const int N = 505;
Node a[N];
long long dp[N][N];
int main() {
  int n;
  long long ans;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%I64d %I64d %I64d", &a[i].val, &a[i].cost, &a[i].num);
  sort(a + 1, a + n + 1, [&](Node x, Node y) { return x.cost > y.cost; });
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      if (j < i)
        dp[i][j] = max(
            dp[i][j], dp[i - 1][j] + max(a[i].val - a[i].cost * a[i].num, 0LL));
      if (j > 0)
        dp[i][j] =
            max(dp[i][j], dp[i - 1][j - 1] + a[i].val - a[i].cost * (j - 1));
    }
  }
  ans = 0;
  for (int i = 0; i <= n; i++) ans = max(ans, dp[n][i]);
  printf("%I64d\n", ans);
  return 0;
}
