#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T &x) {
  char ch = getchar();
  int f = 1;
  x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
template <typename T, typename... Args>
inline void read(T &x, Args &...args) {
  read(x), read(args...);
}
int n;
struct node {
  int a, b, k;
  bool operator<(const node &x) const { return b > x.b; }
} f[505];
long long dp[505][505];
int main() {
  read(n);
  for (register int i = 1; i <= n; ++i) read(f[i].a, f[i].b, f[i].k);
  sort(f + 1, f + n + 1);
  memset(dp, 128, sizeof(dp)), dp[0][0] = 0;
  for (register int i = 1; i <= n; ++i) {
    long long finc = max(0ll, f[i].a - 1ll * f[i].b * f[i].k);
    dp[i][0] = dp[i - 1][0] + finc;
    for (register int j = 1; j <= i; ++j)
      dp[i][j] = max(dp[i - 1][j] + finc,
                     dp[i - 1][j - 1] + f[i].a - 1ll * (j - 1) * f[i].b);
  }
  long long ans = 0;
  for (register int i = 0; i <= n; ++i) chkmax(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}
