#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long dx[4] = {-1, -1, 1, 1};
const long long dy[4] = {-1, 1, -1, 1};
const long long MAX = 3e5 + 50;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long n, m, x, y, k, Q, ans, a;
string second;
vector<pair<long long, pair<long long, long long> > > off;
long long dp[550];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> x >> y >> k, off.push_back({y, {x, k}});
  sort(off.begin(), off.end());
  reverse(off.begin(), off.end());
  for (int i = 0; i < n; ++i)
    for (int j = n - 1; j >= 0; --j) {
      dp[j + 1] =
          max(dp[j + 1], dp[j] + off[i].second.first - j * off[i].first);
      dp[j] = max(dp[j], dp[j] + off[i].second.first -
                             off[i].second.second * off[i].first);
    }
  for (int i = 0; i <= n + 1; ++i) ans = max(ans, dp[i]);
  cout << ans << '\n';
  return 0;
}
