#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	pair<int, int> c[100];
	for (int i = 0; i < n; ++i)
		scanf("%d %d", &c[i].first, &c[i].second);

	int d[100][100];
	for (int i = 0; i < 100; ++i)
		for (int j = 0; j < 100; ++j)
			d[i][j] = INT_MAX;
	for (int i = 0; i < 100; ++i)
		d[i][i] = 0;

	for (int k = 1; k < n; ++k)
		for (int i = 0; i < n-k; ++i)
			for (int j = i; j < i+k; ++j)
				d[i][i+k] = min(d[i][i+k]
			, d[i][j]+d[j+1][i+k] + c[i].first*c[j].second*c[j+1].first*c[i+k].second);

	printf("%d\n", d[0][n-1]);
	return 0;
}