#include <bits/stdc++.h>
using namespace std;
typedef struct loan {
  long long a, b, k;
} LOAN;
bool cmp(LOAN a, LOAN b) { return (a.b > b.b); }
LOAN A[505];
int n, i, j;
long long Dp[505], rez;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> A[i].a >> A[i].b >> A[i].k;
  sort(A + 1, A + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    for (j = n; j >= 1; j--) {
      Dp[j] = max(Dp[j], Dp[j - 1] + A[i].a - A[i].b * (j - 1));
      Dp[j - 1] += max(A[i].a - A[i].b * A[i].k, 0LL);
      rez = max(rez, Dp[j]);
      rez = max(rez, Dp[j - 1]);
    }
  }
  cout << rez << "\n";
  return 0;
}
