#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>
#include <cassert>
  
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);

vector<pii> v;

ll dp[110][110];

ll f(int l, int r){
	if(dp[l][r] != -1) return dp[l][r];
	assert(l >= 0 && r < v.size());
	ll ret = 1e18;
	for(int i = l; i < r; i++) {
		ret = min(ret, f(l, i) + f(i+1, r) + v[l].fi*v[i].se*v[i+1].fi*v[r].se);
	}
	return dp[l][r] = ret;
}

int main(){
	int n;
	cin>>n;
	v.resize(n);
	rep(i, n) cin>>v[i].fi>>v[i].se;
	rep(i, 110) rep(j, 110) dp[i][j] = -1;
	rep(i, 110) dp[i][i] = 0;
	cout<<f(0, n-1)<<endl;
}