#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(nullptr));
const int MAXN = 630, INF = 1e9 + 7, LOG = 21;
long long n, a[MAXN], b[MAXN], k[MAXN];
vector<pair<long long, long long>> g;
long long dp[MAXN][MAXN];
bool key(pair<long long, long long> A, pair<long long, long long> B) {
  return A.first > B.first;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> k[i];
    g.push_back({b[i], i});
  }
  sort(g.begin(), g.end(), key);
  for (int i = 1; i <= n; i++) {
    dp[i][0] =
        dp[i - 1][0] +
        max(0ll, a[g[i - 1].second] - b[g[i - 1].second] * k[g[i - 1].second]);
    for (long long j = 1; j <= n; j++) {
      dp[i][j] = max(
          dp[i - 1][j] + max(0ll, a[g[i - 1].second] -
                                      b[g[i - 1].second] * k[g[i - 1].second]),
          dp[i - 1][j - 1] + a[g[i - 1].second] - b[g[i - 1].second] * (j - 1));
    }
  }
  cout << *max_element(dp[n], dp[n] + n + 1);
  return 0;
}
