#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

int n;
int top[100], bottom[100];
int dp[100][100];

int rec(int l, int r)
{
	//printf("l = %d, r = %d\n", l, r);
	if (dp[l][r] != -1) return dp[l][r];

	int res = INT_MAX;
	if (l == r)
	{
		res = 0;
	} else if (l + 1 == r) {
		res = top[l] * bottom[l] * top[r] * bottom[r];
	} else {
		//cout << "YES" << endl;
		for (int i=l; i<=r-1; i++)
		{
			res = min(res, rec(l, i) + rec(i + 1, r) + top[l] * bottom[i] * top[i+1] * bottom[r]);
		}
	}

	return dp[l][r] = res;
}

signed main()
{
	cin >> n;
	rep(i,n) cin >> top[i] >> bottom[i];

	memset(dp, -1, sizeof(dp));
	cout << rec(0, n - 1) << endl;
}