#include <iostream>
using namespace std;

const unsigned int INF = 1 << 31;
unsigned int dp[101][101], a[101], b[101];
int n;

// l..r の最小コストを返す
// dp[i][j] := 山i..jの最小コスト
unsigned int solve(int l, int r){
	if( dp[l][r] != INF ) return dp[l][r];
	if( l+1 == r ) return dp[l][r] = a[l] * b[l] * a[r] * b[r];
	if( l == r ) return dp[l][r] = 0;
	
	unsigned int res = INF;
	for(int i=l ; i < r ; i++ ){
		// l..i i..r に分割
		unsigned int cost = b[l] * a[i] * b[i+1] * a[r] + solve(l,i) + solve(i+1,r);
		res = min( res , cost );
	}
	return dp[l][r] = res;
}

void ini(){
	for(int i=0 ; i < 101 ; i++ ){
		for(int j=0 ; j < 101 ; j++ ){
			dp[i][j] = INF;
		}
	}
}

int main(){
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		cin >> a[i] >> b[i];
	}
	ini();
	unsigned int ans = solve(0,n-1);
	cout << ans << endl;
}