#include<stdio.h>
#include<limits.h>
#include<algorithm>
int memo[100][100];
int t[100],b[100];
int n;
int F(int l,int r)
{
	if(memo[l][r])return memo[l][r];
	if(l==r)return 0;
	int a=INT_MAX,i;
	for(i=l;i+1<=r;++i)a=std::min(a,t[l]*b[i]*t[i+1]*b[r]+F(l,i)+F(i+1,r));
	return memo[l][r]=a;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d%d",&t[i],&b[i]);
	printf("%d\n",F(0,n-1));
	return 0;
}