#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int n;
long long dp[510], ans;
struct mmp {
  long long a, b, c;
  bool operator<(const mmp &op) const { return b > op.b; }
} f[510];
int main() {
  int i, j;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%I64d%I64d%I64d", &f[i].a, &f[i].b, &f[i].c);
  sort(f + 1, f + n + 1);
  for (i = 1; i <= n; i++) {
    for (j = i - 1; j >= 0; j--) {
      dp[j + 1] = max(dp[j + 1], dp[j] + f[i].a - f[i].b * j);
      dp[j] = max(dp[j], dp[j] + f[i].a - f[i].b * f[i].c);
      ans = max(ans, max(dp[j], dp[j + 1]));
    }
  }
  cout << ans << "\n";
  return 0;
}
