#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define INF 1000000000

int top[111];
int bot[111];

int memo[111][111];
int saiki(int st,int en){
	if(st+1 == en)return 0;
	if(memo[st][en]!=0)return memo[st][en];
	
	int cost = INF;
	
	for(int i=st+1;i<en;i++){
		int next = 0;
		next += saiki(st,i);
		next += saiki(i,en);
		next += top[st]*bot[i-1]*top[i]*bot[en-1];
		
		cost = min(next,cost);
	}
	
	return memo[st][en] = cost;
}

int main(){
	int n;
	cin>>n;
	
	rep(i,n)cin>>top[i]>>bot[i];
	
	int ans = saiki(0,n);
	printf("%d\n",ans);
}