#include <cstring>
#include <iostream>
using namespace std;
const int MAX_N = 100;
int a[MAX_N], b[MAX_N];
int memo[MAX_N + 1][MAX_N + 1];

int getMinCost(int bottom, int top) {
	if (bottom == top) return 0;
	if (memo[bottom][top] != -1) {
		return memo[bottom][top];
	}
	int cost = 0x7ffffff;
	for (int i = bottom; i < top; i++) {
		cost = min(cost, getMinCost(bottom, i) + getMinCost(i + 1, top) + a[bottom] * b[i] * a[i + 1] * b[top]);
	}
	return memo[bottom][top] = cost;
}

int main () {
	int n;
	cin >> n;
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	cout << getMinCost(0, n - 1) << endl;
	return 0;
}