#include <bits/stdc++.h>
using namespace std;
int n;
struct credit {
  long long a, b, k;
};
bool operator<(credit x, credit y) { return x.b > y.b; }
credit v[502];
long long dp[502][502];
long long ans = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i].a >> v[i].b >> v[i].k;
  sort(v + 1, v + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= n; j++) {
      dp[i][j] = dp[i - 1][j];
      if (v[i].a - v[i].b * v[i].k > 0) dp[i][j] += v[i].a - v[i].b * v[i].k;
      if (j > 0)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + v[i].a - v[i].b * (j - 1));
      if (i == n) ans = max(ans, dp[i][j]);
    }
  cout << ans << "\n";
  return 0;
}
