#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100], b[100], dp[100][101];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) dp[i][j] = j - i - 1 ? 999999999 : 0;
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 0; i + j <= n; j++) {
			for (int k = j; k < i + j; k++) dp[j][i + j] = min(dp[j][i + j], dp[j][k] + dp[k][i + j] + a[j] * b[k - 1] * a[k] * b[i + j - 1]);
		}
	}
	cout << dp[0][n] << endl;
	return 0;
}