#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 0xffffffff;

signed main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<vector<int>> dp(n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++) {
		dp[i][i] = 0;
	}
	for (int k = 1; k < n; k++) {
		for (int i = 0; i + k < n; i++) {
			for (int j = i; j < i + k; j++) {
				dp[i][i + k] = min(dp[i][i + k], dp[i][j] + dp[j + 1][i + k] + a[i] * b[j] * a[j + 1] * b[i + k]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}