#include <iostream>

using namespace std;

int n;
struct doll
{
    int vIn,vOut,cost;
}x[1001];

int mn[1001];
int mx[1001];
bool marc[1001];
int total;

void citire()
{
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>x[i].vOut>>x[i].vIn>>x[i].cost;
        total += x[i].vIn*x[i].cost;
    }
}

void formare()
{
    int mnLocal;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            if(x[i].vOut<x[j].vIn)
            {
                mnLocal = -1*(x[i].vOut * x[j].cost);
                if(mnLocal < mn[i])
                    if(marc[j] == false || (marc[j] == true && mnLocal < mx[j]))
                    {
                        mn[j] = mnLocal;
                        mx[j] = mnLocal;
                        marc[j] = true;
                    }
            }
}

void aflareRezultat()
{
    for(int i=1;i<=n;++i)
        total += mn[i];
}

int main()
{
    citire();
    formare();
    aflareRezultat();
    cout<<total;
    return 0;
}