#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 9;
const long long mod = 998244353;
const long long Inf = 1e18;
long long dp[509][509];
long long a[N], b[N], k[N], ord[N];
bool cmp(int x, long long y) { return b[x] > b[y]; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i)
    scanf("%lld%lld%lld", &a[i], &b[i], &k[i]), ord[i] = i;
  sort(ord + 1, ord + 1 + n, cmp);
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (1); j < (n + 1); ++j) dp[i][j] = -Inf;
  for (int i = (1); i < (n + 1); ++i) {
    for (int j = (1); j < (i + 1); ++j) {
      dp[i][j] =
          max(dp[i][j], dp[i - 1][j - 1] + a[ord[i]] - b[ord[i]] * (j - 1));
      dp[i][j - 1] =
          max(dp[i][j - 1],
              dp[i - 1][j - 1] + max(0ll, a[ord[i]] - b[ord[i]] * k[ord[i]]));
    }
  }
  long long res = 0;
  for (int i = (0); i < (n + 1); ++i) res = max(res, dp[n][i]);
  cout << res;
}
