#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
int dp[101][101];vector<P> v;
const int INF=(1<<31)-1;
int dfs(int d,int u){
	if(u==d) return 0;
	if(dp[d][u]!=INF) return dp[d][u];
	int minCost=INF;
	for(int i = d; i < u; i++)
		minCost=min(minCost,v[d].second*v[u].first*v[i].first*v[i+1].second+dfs(d,i)+dfs(i+1,u));
	dp[d][u]=minCost;
	return dp[d][u];
}
int main(){
	int n;cin>>n;
	for(int i = 0; i < n; i++){
		int over,down;
		cin>>over>>down;
		v.push_back(P(over,down));
	}
	reverse(v.begin(),v.end());
	for(int i = 0; i < 101; i++)
		fill(dp[i],dp[i]+101,INF);
	cout<<dfs(0,n-1)<<endl;
	return 0;
}