#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e17;
vp in;
vvi dp;
int f(int a,int b){
	if(dp[a][b]!=inf)return dp[a][b];
	if(b==2){
		return dp[a][b]=in[a].first*in[a].second*in[a+b-1].first*in[a+b-1].second;
	}
	ll mi=f(a,b-1)+in[a].first*in[a+b-2].second*in[a+b-1].first*in[a+b-1].second;
	mi=min<ll>(mi,f(a+1,b-1)+in[a].first*in[a].second*in[a+1].first*in[a+b-1].second);
	rep(i,b-3)mi=min<ll>(mi,f(a,i+2)+f(a+i+2,b-i-2)+in[a].first*in[a+i+1].second*in[a+i+2].first*in[a+b-1].second);
	return dp[a][b]=mi;
}
int main(){
	int n;
	cin>>n;
	in=vp(n);
	dp=vvi(n,vi(n+1,inf));
	rep(i,n)cin>>in[i].first>>in[i].second;
	if(n==1)cout<<0<<endl;
	else cout<<f(0,n)<<endl;
}