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

using namespace std;
typedef pair<int, int> P;
static const int INF = 1e9;
int dp[101][101];

void solve()
{
	int n;
	cin >> n;
	vector<P> card(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> card[i].first >> card[i].second;
	}
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			dp[i][j] = INF;
		}
		dp[i][i] = 0;
	}
	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j <= n - i; ++j)
		{
			for (int k = j; k < j + i; ++k)
			{
				int cost = card[j].first * card[k].second * card[k + 1].first * card[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;
}

int main()
{
	solve();
	return(0);
}