#include <bits/stdc++.h>
using namespace std;
struct Struct {
  long long X;
  long long Y;
  long long Z;
};
Struct Data[501];
long long Dp[501];
int main(void) {
  register int i, j;
  register long long Total;
  cin >> Total;
  for (i = 1; i <= Total; i++) {
    cin >> Data[i].X >> Data[i].Y >> Data[i].Z;
  }
  sort(Data + 1, Data + Total + 1,
       [](Struct i, Struct j) { return i.Y > j.Y; });
  for (i = 1; i <= Total; i++) {
    for (j = Total - 1; j >= 0; j--) {
      Dp[j + 1] = max(Dp[j + 1], Dp[j] + Data[i].X - Data[i].Y * j);
      Dp[j] = max(Dp[j], Dp[j] + Data[i].X - Data[i].Z * Data[i].Y);
    }
  }
  register long long Ans;
  Ans = 0;
  for (i = 0; i <= Total; i++) {
    Ans = max(Ans, Dp[i]);
  }
  cout << Ans << endl;
  return 0;
}
