#include<iostream>
#include<set>
#include<cstring>
#include<algorithm>

using namespace std;

int CardDataA[100], CardDataB[100];
int DpResult[100][100];
const int INF = 50000000;

void Init() {
	memset(CardDataA, 0, sizeof(CardDataA));
	memset(CardDataB, 0, sizeof(CardDataB));

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			DpResult[i][j] = INF;
		}
	}

	for (int i = 0; i < 100; i++) {
		DpResult[i][i] = 0;
	}
}

void solve(int n) {
	int current;

	for (int k = 1; k < n; k++) {
		for (int i = 0; i+k < n; i++) {
			for (int j = i; j < i + k; j++) {
				current = CardDataA[i] * CardDataB[j] * CardDataA[j + 1] * CardDataB[i + k];
				DpResult[i][i+k] = min(DpResult[i][i+k], DpResult[i][j] + DpResult[j+1][i+k] + current);
				//cout << "current:"<<current << "  Dp["<<i<<"]"<< "[" << i+k << "]=" << DpResult[i][i+k]<< endl;
			}
		}
	}
		
}

int main() {
	int n;

	Init();

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> CardDataA[i] >> CardDataB[i];
	}
	/*n = 0;
	while (CardDataA[n] != 0) {
		cout << CardDataA[n] << "  " << CardDataB[n] << endl;
		n++;
	}*/
	solve(n);
	cout << DpResult[0][n-1] << endl;

	return 0;
}


