#include <bits/stdc++.h>
using namespace std;
int N;
struct offer {
  long long a, b, k;
} o[510];
bool cmp(offer o1, offer o2) { return o1.b > o2.b; }
long long f[510][510];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%lld%lld%lld", &o[i].a, &o[i].b, &o[i].k);
  }
  sort(o + 1, o + N + 1, cmp);
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      f[i][j] = f[i - 1][j];
      f[i][j] = max(f[i][j], f[i - 1][j] + o[i].a - o[i].b * o[i].k);
      if (j > 0) {
        f[i][j] = max(f[i][j], f[i - 1][j - 1] + o[i].a - o[i].b * (j - 1));
      }
      ans = max(ans, f[i][j]);
    }
  }
  printf("%lld\n", ans);
}
