#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int n,a[100],b[100];
int dp[101][101];

int main(){
	cin>>n; FOR(i,n) cin>>a[i]>>b[i];
	memset(dp,0x3f,sizeof(dp));
	FOR(i,n) dp[i][i+1] = 0;
	for(int i = 2; i <= n; i++){
		for(int l = 0; l + i <= n; l++){
			int r = l + i;
			for(int k = l+1; k < r; k++){
				dp[l][r] = min(dp[l][r],dp[l][k] + dp[k][r] + a[l] * b[k-1] * a[k] * b[r-1]);
			}
		}
	}

	cout << dp[0][n] << endl;

	return 0;
}