#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int dp[1024][1024], num;
struct deck { int top, bottom; };
const int  INF = (1 << 30);

int main()
{

	cin >> num;
	vector<deck> mount(128);

	for(int i = 0; i < num; i++)
	{
		cin >> mount[i].top >> mount[i].bottom;

		for(int j = 0; j < num; j++)
		{
			if(i == j) continue;
			dp[i][j] = INF;
		}

	}


	for(int w = 1; w < num; w++)
	{
		for(int i = 0; i + w < num; i++)
		{
			int j = i + w;
			for(int k = i; k < j; k++)
			{
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + mount[i].top * mount[k].bottom * mount[k+1].top * mount[j].bottom );
			}
		}
	}

	cout << dp[0][num -1] << endl;
}