#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i,0,(n))
#define pb(n) push_back(n)
#define mp(n,m) make_pair(n, m)
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;


bool compFi(pii p1, pii p2){
	if(p1.fi!=p2.fi){
		return p1.fi > p2.fi;
	}
	return p1.se < p2.se;
}
bool compSe(pii p1, pii p2){
	if(p1.se != p2.se){
		return p1.se > p2.se;
	}
	return p1.fi < p1.se;
}

int main(){
	int n;
	cin>>n;
	vector<pii> v(n);
	rep(i, n){
		cin>>v[i].fi>>v[i].se;
	}
	int ans = 0;
	while(v.size() > 1){
		vector<pii> s = v, t = v;
		sort(all(s), compFi);
		sort(all(t), compSe);
		pii cs = s.back(), ct = t.back();
		s.pop_back(); t.pop_back();
		sort(all(s), compSe);
		sort(all(t), compFi);
		if(cs.fi * s.back().se < ct.se * t.back().fi){
			pii ss = s.back(); s.pop_back();
			ans += cs.fi * cs.se * ss.fi * ss.se;
			s.push_back(pii(cs.fi, ss.se));
			v = s;
		}else{
			pii tt = t.back(); t.pop_back();
			ans += ct.fi * ct.se * tt.fi * tt.se;
			t.push_back(pii(tt.fi, ct.se));
			v = t;
		}
	}
	println(ans);
}