#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

#define INF (1 << 30)

using namespace std;

int DP[200][200]; // DP[i][j] : i????????????????????????j???????±±????????¨????????¨??????????°????

int main(){
	
	int n;
	
	int a[200], b[200];
	
	for(int i = 0; i < 200; i++){
		for(int j = 0; j < 200; j++){
			DP[i][j] = INF;
		}
	}
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		DP[i][1] = 0;
	}
	
	for(int loop = 2; loop <= n; loop++){
		for(int i = 0; i < n - loop + 1; i++){
			for(int j = 1; j < loop; j++){
				DP[i][loop] = min(DP[i][loop], DP[i][j] + DP[i + j][loop - j] + a[i] * b[i + j - 1] * a[i + j] * b[i + loop - 1]);
			}
			//cout << DP[i][loop] << " ";
		}
		//cout << endl;
	}
	
	cout << DP[0][n] << endl;
	
	return 0;
}