#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<=n;i++)

int n,a[100],b[100],dp[100][100];

int main(){
	cin>>n;
	rep(i,n)fill(dp[i],dp[i]+n,INF);
	rep(i,n){
		cin>>a[i]>>b[i];
		dp[i][i]=0;
	}
	rep2(i,1,n)rep(j,n-i+1)rep(k,i)dp[j][j+i]=min(dp[j][j+i],dp[j][j+k]+dp[j+k+1][j+i]+a[j]*b[j+k]*a[j+k+1]*b[j+i]);
	cout<<dp[0][n-1]<<endl;
}