#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 + 10;
int n;
struct offer {
  long long a, b, k;
} o[maxn];
long long dp[maxn];
inline bool cmp(offer x, offer y) { return x.b > y.b; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld%lld%lld", &o[i].a, &o[i].b, &o[i].k);
  sort(o + 1, o + 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] + o[i].a - o[i].b * j);
      dp[j] = max(dp[j], dp[j] + o[i].a - o[i].k * o[i].b);
    }
  long long ans = 0;
  for (int i = 0; i <= n; i++) ans = max(ans, dp[i]);
  printf("%lld\n", ans);
}
