//#include<fstream>
#include<iostream>
#include<algorithm>
using namespace std;
typedef struct doll{ int out,in,cost; }T;
T a[1003];
bool viz[1003];
bool cmp(const T &a,const T &b){
     if(a.cost!=b.cost) return (a.cost < b.cost);
     else if(a.in!=b.in) return (a.in < b.in); 
     else return (a.out<b.out);
     }

int main(){
/*
   #ifndef ONLINE_JUDGE
   ifstream cin("dolls.in");
   ofstream cout("dolls.out");
   #endif
   */
   int N,i,j,x,y,z,found;
   long long ans=0;
   
   //ios_base::sync_with_stdio(0);
   
   cin>>N;
   for(i=1;i<=N;++i)
   {
     cin>>x>>y>>z;
     a[i].out=x;
     a[i].in=y;
     a[i].cost=z;                
   }
    
   sort(a+1,a+N+1,cmp);
   
   for(i=N;i>0;--i)
     {
       found = 0;
       for(j=i-1;j>0;--j)
         if(!viz[j] && a[i].in > a[j].out)
         {
           viz[j]=1;
           ans += (long long)(a[i].in-a[j].out) * a[i].cost;
           found = 1;
		   break;   
         }
       if(!found) ans += (long long)a[i].in * a[i].cost;     
     }
   
   cout<<ans<<'\n';
   
 return 0;   
}