#include <bits/stdc++.h>
using namespace std;
bool comp(array<long long, 3> a, array<long long, 3> b) { return a[1] < b[1]; }
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<array<long long, 3>> offers(n);
  for (long long i = 0; i < n; ++i) {
    cin >> offers[i][0] >> offers[i][1] >> offers[i][2];
  }
  sort((offers).begin(), (offers).end(), comp);
  long long dp[n + 1][n + 1];
  for (long long i = 0; i <= n; ++i) {
    fill(dp[i], dp[i] + n + 1, -1e18);
  }
  dp[n][0] = 0;
  for (long long i = n - 1; i >= 0; --i) {
    for (long long j = 0; j <= n; ++j) {
      if (j && dp[i + 1][j - 1] != -1e18) {
        dp[i][j] = dp[i + 1][j - 1] + offers[i][0] -
                   min(j - 1, offers[i][2]) * offers[i][1];
      }
      if (dp[i + 1][j] != -1e18) {
        dp[i][j] = max(dp[i][j], dp[i + 1][j]);
        dp[i][j] = max(dp[i][j], dp[i + 1][j] + offers[i][0] -
                                     offers[i][2] * offers[i][1]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= n; ++i) {
    ans = max(ans, dp[0][i]);
  }
  cout << ans << "\n";
}
