#include <bits/stdc++.h>
using namespace std;
const int N = 550;
const int M = 1e9 + 7;
const long long INF = 1e18;
struct offer {
  long long a, b, k;
  bool operator<(const offer& h) const { return b > h.b; }
};
long long dp[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<offer> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i].a >> d[i].b >> d[i].k;
  }
  sort(d.begin(), d.end());
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= 0; j--) {
      if (j <= d[i].k) {
        dp[j + 1] = max(dp[j + 1], dp[j] + d[i].a - d[i].b * j);
      }
      dp[j] = max(dp[j], dp[j] + d[i].a - d[i].b * d[i].k);
    }
  }
  cout << *max_element(dp, dp + n + 1) << "\n";
}
