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

int main(){
	int n;
	int a[100],b[100];
	int cb[100][100];
	//b > a
	for(int i = 0; i < 100; i++){
		for(int j = i; j < 100; j++){
			cb[i][j] = 2147483647;
		}
	}

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}		// 入力

	for(int i = 0; i < n; i++){
		cb[i][i] = 0;
		if(i != (n - 1)){
			cb[i][i+1] = a[i] * b[i] * a[i+1] * b[i+1];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n-i; j++){		//cd[j][i]
			for(int k = j; k < i+j; k++){
				cb[j][i] = min(cb[j][i] , cb[j][k]+cb[k+1][i]+a[j]*b[k]*a[k+1]*b[i]);
			}
		}
	}
	cout << cb[0][n-1] << endl;
	return 0;
}