#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int N = 501;
long long dp[N][N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<long long>> v;
  for (int i = 0; i < n; i++) {
    long long a, b, k;
    cin >> a >> b >> k;
    v.push_back({-b, a, k});
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i + 1][j] =
          max(dp[i + 1][j], max(0ll, v[i][1] + v[i][0] * v[i][2]) + dp[i][j]);
      dp[i + 1][j + 1] =
          max(dp[i + 1][j + 1], v[i][1] + v[i][0] * j + dp[i][j]);
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) ans = max(ans, dp[n][i]);
  cout << ans;
  return 0;
}
