#include <bits/stdc++.h>
using namespace std;
const int N = 505;
struct dat {
  int a, b, k;
  bool operator<(const dat x) const { return b > x.b; }
} p[N];
void checkmax(long long &x, long long y) {
  if (x < y) x = y;
}
int n;
long long dp[N][N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &p[i].a, &p[i].b, &p[i].k);
  }
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i][j] = max(dp[i - 1][j],
                     dp[i - 1][j] + 1ll * p[i].a - 1ll * p[i].b * p[i].k);
      if (j != 0)
        checkmax(dp[i][j], dp[i - 1][j - 1] + 1ll * p[i].a -
                               1ll * p[i].b * min(p[i].k, j - 1));
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) checkmax(ans, dp[n][i]);
  printf("%lld\n", ans);
}
