#include<iostream>
#include<algorithm>
using namespace std;
long memo[100][100];
long a[100],b[100];
long f(int l,int r)
{
	if(memo[l][r]>0)return memo[l][r];
	else if(l==r)return 0;
	long ans=1LL<<32;
	for(int i=l;i<r;i++)
	{
		ans=min(ans,f(l,i)+f(i+1,r)+a[l]*b[i]*a[i+1]*b[r]);
	}
	return memo[l][r]=ans;
}
main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	cout<<f(0,n-1)<<endl;
}

