#include <bits/stdc++.h>
using namespace std;
struct offer {
  long long a;
  long long b;
  long long k;
  bool operator<(const offer &other) const { return b > other.b; }
};
const int MAXN = 500;
offer v[MAXN + 1];
long long dp[MAXN + 1];
int main() {
  int i, j, n;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> v[i].a >> v[i].b >> v[i].k;
  sort(v + 1, v + n + 1);
  for (i = 1; i <= n; i++) {
    for (j = n - 1; j >= 0; j--) {
      dp[j + 1] = max(dp[j + 1], dp[j] + v[i].a - v[i].b * j);
      dp[j] = max(dp[j], dp[j] + v[i].a - v[i].b * v[i].k);
    }
  }
  long long sol = 0;
  for (i = 0; i <= n; i++) sol = max(sol, dp[i]);
  cout << sol;
  return 0;
}
