#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll dp[N],sum[N],sump[N],h,t,q[N];
ll x[N],c[N],p[N],n;
ll X(ll j){
return sump[j];
}
ll Y(ll j){
return sum[j]+dp[j];
}
long double slope(ll i,ll j){
return (long double)(Y(j)-Y(i))/(X(j)-X(i));
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>x[i]>>p[i]>>c[i];
sump[i]=sump[i-1]+p[i];
sum[i]=sum[i-1]+x[i]*p[i];
}
for(int i=1;i<=n;i++){
while(h<t && slope(q[h],q[h+1])<=x[i]) h++;
int j=q[h];
dp[i]=dp[j]+x[i]*(sump[i]-sump[j])-sum[i]+sum[j]+c[i];
while(h<t && slope(q[t-1],q[t])>=slope(q[t-1],i)) t--;
q[++t]=i;
}
cout<<dp[n]<<endl;
return 0;
}