#include <bits/stdc++.h>
using namespace std;
pair<long long, pair<long long, long long> > a[505];
long long dp[505];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].second.first >> a[i].first >> a[i].second.second;
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = n - 1; j >= 0; j--) {
      dp[j + 1] =
          max(dp[j] + a[i].second.first - j * a[i].first, 1LL * dp[j + 1]);
      dp[j] = max(dp[j] + a[i].second.first - a[i].second.second * a[i].first,
                  dp[j]);
    }
  }
  cout << *max_element(dp, dp + n + 1) << '\n';
  return 0;
}
