#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, k;
};
bool operator<(node x, node y) { return x.b > y.b; }
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return x * f;
}
const int N = 505;
node data[N];
long long dp[N][N];
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) {
    data[i].a = read();
    data[i].b = read();
    data[i].k = read();
  }
  sort(data + 1, data + n + 1);
  for (int i = 1; i <= n; ++i) dp[0][i] = -1LL << 60;
  for (int i = 1; i <= n; ++i) {
    long long W = max(0LL, data[i].a - 1LL * data[i].b * data[i].k);
    dp[i][0] = dp[i - 1][0] + W;
    for (int j = 1; j <= i; ++j)
      dp[i][j] = max(dp[i - 1][j] + W,
                     dp[i - 1][j - 1] + data[i].a - 1LL * (j - 1) * data[i].b);
  }
  long long ans = 0;
  for (int i = 0; i <= n; ++i) ans = max(ans, dp[n][i]);
  printf("%lld\n", ans);
  return 0;
}
