#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <class T>
bool ckmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
const int N = 505;
struct node {
  long long a, b, k;
} a[N];
int n;
long long dp[N][N], ans;
inline bool cmp(const node &a, const node &b) { return a.b > b.b; }
signed main() {
  n = read();
  for (int i = 1, iend = n; i <= iend; ++i) {
    a[i].a = read(), a[i].b = read(), a[i].k = read();
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1, iend = n; i <= iend; ++i) {
    for (int j = 0, jend = i; j <= jend; ++j) {
      dp[i][j] = dp[i - 1][j];
      ckmax(dp[i][j], dp[i - 1][j] + a[i].a - a[i].k * a[i].b);
      if (j) ckmax(dp[i][j], dp[i - 1][j - 1] + a[i].a - (j - 1) * a[i].b);
    }
  }
  for (int i = 0, iend = n; i <= iend; ++i) ckmax(ans, dp[n][i]);
  cout << ans << '\n';
  return 0;
}
