#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;

#define FOR(i, n) for(int i=0;i<(int)n;i++)
#define ALL(c) (c).begin(),(c).end()
#define VCI vector<int>
#define VCS vector<string>
#define pb push_back
#define SZ size()

#define INF 2147483647

int dp[110][110];

int main() {
	int n;
	cin >> n;
	
	VCI a(n);
	VCI b(n);
	for (int i=0; i<n; i++) {
		cin >> a[i] >> b[i];
		for (int j=0; j<n; j++)
			i==j ? dp[i][j] = 0 : dp[i][j] = INF;
	}

	for (int i=0; i+1<n; i++)
		dp[i][i+1] = a[i]*b[i]*a[i+1]*b[i+1];

	for (int i=2; i<=n; i++) {
		for (int j=0; j+i<n; j++) {
			for (int k=0; k<i; k++) {
				dp[j][j+i] = min(dp[j][j+i], dp[j][j+k]+dp[j+k+1][j+i]+a[j]*b[j+k]*a[j+k+1]*b[j+i]);
			}
		}
	}

	cout << dp[0][n-1] << endl;

	return 0;
}