#include <bits/stdc++.h>
using namespace std;
double PI = 3.141592653589793;
const double EPS = 1e-6;
const int N = 1e6 + 5;
const long long mod = 1e9 + 7;
int oo = 1e9;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
pair<long long, pair<long long, long long> > t[505];
int n;
long long dp[505][505];
long long solve(int i, int take) {
  if (i == n) return 0;
  long long &ret = dp[i][take];
  if (ret != -1) return ret;
  ret = -1e18;
  ret = max(ret, solve(i + 1, take));
  ret = max(ret, t[i].second.first - t[i].first * t[i].second.second +
                     solve(i + 1, take));
  ret =
      max(ret, t[i].second.first - t[i].first * take + solve(i + 1, take + 1));
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) {
    scanf("%lld%lld%lld", &t[i].second.first, &t[i].first, &t[i].second.second);
  }
  sort(t, t + n);
  reverse(t, t + n);
  long long ans = -1;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i <= n; i++) ans = max(ans, solve(0, i));
  printf("%lld", ans);
}
