#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int n;
	cin>>n;
	vector<pii> card(n);
	rep(i,n)cin>>card[i].first>>card[i].second;
	
	
	ll ans = 0;
	while(card.size()>1){
		int maxvalue=-1;
		pii maxpos=pii(-1,-1);
		rep(i,card.size()){
			rep(j,card.size()){
				if(i==j)continue;
				if(maxvalue<card[i].second*card[j].first){
					maxpos=pii(i,j);
					maxvalue=card[i].second*card[j].first;
				}
			}
		}
		
		ans+=maxvalue*card[maxpos.first].first*card[maxpos.second].second;
//		cout<<maxvalue*card[maxpos.first].first*card[maxpos.second].second<<endl;
		
		card[maxpos.first]=pii(card[maxpos.first].first,card[maxpos.second].second);
		card.erase(card.begin()+maxpos.second);
	}
	cout<<ans<<endl;
}