#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int n;
int a[100], b[100];
int memo[100][100];

int recur(int left, int right){
	if(memo[left][right] == -1){
		int ret = INT_MAX;

		if(left == right){
			ret = 0;
		}
		else{
			for(int mid = left; mid < right; ++mid){
				int cost = recur(left, mid) + recur(mid + 1, right) + a[left] * b[mid] * a[mid + 1] * b[right];
				ret = min(ret, cost);
			}
		}
		memo[left][right] = ret;
	}

	return memo[left][right];
}

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){
			memo[i][j] = -1;
		}
	}

	int ans = recur(0, n - 1);
	cout << ans << endl;
}