#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>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<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;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n;
	cin>>n;
	vector<pii> v(n);
	rep(i, n) cin>>v[i].fi>>v[i].se;
	ll ans = 0LL;
	while(v.size()>1) {
		int idx = -1, val = 1e9;
		for(int i = 0; i+1 < v.size(); i++) {
			int nval = v[i].fi * v[i+1].se;
			if(nval < val) val = nval, idx = i;
		}
		ans += v[idx].fi * v[idx].se * v[idx + 1].fi * v[idx + 1].se;
		v[idx] = {v[idx].fi,v[idx+1].se};
		for(int i = idx+1; i +1 < v.size(); i++){
			v[i] = v[i+1];
		}
		v.pop_back();
	}
	cout<<ans<<endl;
}