#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Credit {
  int a, b, k;
  bool operator<(const Credit& c) const { return b > c.b; }
};
int N;
vector<Credit> a;
vector<ll> dp;
void ReadData();
void Solve();
int main() {
  ReadData();
  Solve();
  return 0;
}
void ReadData() {
  cin >> N;
  a = vector<Credit>(N);
  for (int i = 0; i < N; ++i) cin >> a[i].a >> a[i].b >> a[i].k;
}
void Solve() {
  sort(a.begin(), a.end());
  dp = vector<ll>(N + 1);
  for (const Credit& c : a) {
    for (int i = N - 1; i >= 0; --i) {
      dp[i + 1] = max(dp[i + 1], dp[i] + c.a - 1ll * i * c.b);
      dp[i] = max(dp[i], dp[i] + c.a - 1ll * c.k * c.b);
    }
  }
  ll ans{0};
  for (int i = 0; i <= N; ++i) ans = max(ans, dp[i]);
  cout << ans << '\n';
}
