#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <climits>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define FILL(mat, x) memset(mat, x, sizeof(mat))
#define BIT(n, b) ((n>>b) & 1)

#define INF 1<<31-1
using namespace std;

typedef pair<int,int> paii;
typedef long long ll;

int n;
ll top[256], btm[256], dp[256][256];

ll rec(int lo, int up){
	
	ll res = INF;
	
	if(up <= lo)
		return 0;
	if(dp[lo][up] >= 0)
		return dp[lo][up];
	
	for(int k = lo+1; k <= up; ++k){
		ll tmp = rec(lo, k-1) + rec(k, up) + top[lo]* btm[k-1]* top[k]* btm[up];
		res = min(res, tmp);
	}
	
	return dp[lo][up] = res;	
}

int main(){
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){	
		cin >> top[i] >> btm[i];
	}
	
	NCLR(dp);
	cout << rec(0,n-1) << endl;
	
	return 0;
}