#include <bits/stdc++.h>
const int N = 505;
int n, a[N], b[N], k[N], rk[N];
long long dp[N][N];
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n;
  for (int i = 1; i <= n; ++i) std::cin >> a[i] >> b[i] >> k[i], rk[i] = i;
  std::sort(rk + 1, rk + n + 1, [](int x, int y) { return b[x] > b[y]; });
  std::memset(dp, -0x3f, sizeof dp);
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= i; ++j) {
      for (int t = 0; t < i; ++t) {
        dp[i][j] = std::max(
            dp[i][j], dp[t][j] + a[rk[i]] - (long long)k[rk[i]] * b[rk[i]]);
        if (j)
          dp[i][j] = std::max(dp[i][j], dp[t][j - 1] + a[rk[i]] -
                                            (long long)(j - 1) * b[rk[i]]);
      }
    }
  long long ans = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j) ans = std::max(ans, dp[i][j]);
  std::cout << ans << '\n';
  return 0;
}
