#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

ll dp[102][102];
vector<pii> c;

ll solve(int left,int right){
	if(dp[left][right]!=INF)return dp[left][right];
	
	for(int k=left+1;k<right;k++){
		dp[left][right] = min(solve(left,k)+solve(k,right)+c[left].first*c[k-1].second*c[k].first*c[right-1].second,dp[left][right]);
	}
	return dp[left][right];
}

int main(){
	int n;
	cin>>n;
	c.resize(n);
	rep(i,n)cin>>c[i].first>>c[i].second;
	
	rep(i,102)rep(j,102)dp[i][j]=INF;
	rep(i,n)dp[i][i+1]=0;
	
	cout<<solve(0,n)<<endl;
}