#include <bits/stdc++.h>
using namespace std;
const long long N = 505;
long long dp[N][N], n, ans;
struct Ask {
  long long a, b, k;
} A[N];
long long cmp(Ask x, Ask y) { return x.b < y.b; }
signed main() {
  scanf("%lld", &n);
  long long ans = 0;
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld%lld", &A[i].a, &A[i].b, &A[i].k);
  sort(A + 1, A + n + 1, cmp);
  dp[n + 1][0] = 0;
  for (long long i = n; i; i--) {
    for (long long j = 0; j <= n - i; j++) {
      dp[i][j] = max(dp[i][j], dp[i + 1][j]);
      dp[i][j] = max(dp[i][j], dp[i + 1][j] + (A[i].a - A[i].b * A[i].k));
      dp[i][j + 1] = max(dp[i][j], dp[i + 1][j] + A[i].a - A[i].b * j);
    }
  }
  for (long long i = 0; i <= n; i++) ans = max(ans, dp[1][i]);
  printf("%lld\n", ans);
  return 0;
}
