#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<21

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<pair<int,int> > v;
	long long dp[101][101];

	rep(i,n)
	{
		int a,b;
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}
	
	memset(dp,0x2,sizeof(dp));
	rep(i,n+1) dp[i][i] = 0;
	
	REP(i,1,n)
	{
		rep(j,n-i+1)
		{
			REP(k,j,j+i)
			{
				int cost = v[j].first * v[k].second * v[k+1].first *  v[j+i].second;
				dp[j][j+i] = min(dp[j][j+i],cost+dp[j][k]+dp[k+1][j+i]);
			}
		}
	}

	cout << dp[0][n-1] << endl;

	return 0;
}