#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

#define fi first
#define se second

#define INF (1LL << 31)

typedef pair<long long, long long> pll;

int main() {
	int n;
	vector<pll> in;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		in.push_back(pll(a,b));
	}

	long long dptab[128][128];
	for(int i = 0; i < 128; i++) for(int j = 0; j < 128; j++) dptab[i][j] = INF;

	for(int i = 0; i < n; i++) {
		dptab[0][i] = dptab[1][i] = 0;
		dptab[2][i] = in[i].fi * in[i].se * in[i + 1].fi * in[i + 1].se;
	}
	for(int width = 0; width <= n; width++) {
		for(int start = 0; start < n; start++) {
			for(int div = 1; div < width; div++) {
				dptab[width][start] = min(dptab[width][start],
						dptab[div][start] + dptab[width - div][start + div] + in[start].fi * in[start + div - 1].se * in[start + div].fi * in[start + width - 1].se);
			}
		}
	}

	cout << dptab[n][0] << endl;

	return 0;
}