#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int N = 110;
ll dp[N][N];
int top[N], bot[N];

ll dfs(int l, int r){ // [l, r]
	if(l == r) return 0;
	ll &res = dp[l][r];
	if(res >= 0) return res;

	res = 1ll<<32;
	for(int i = l; i <= r; ++i){
		ll tmp = dfs(l, i)+dfs(i+1, r);
		tmp += top[l]*bot[i]*top[i+1]*bot[r];
		res = min(res, tmp);
	}

	return res;
}

int main(){
	int n;
	cin >> n;
	rep(i, n) cin >> top[i] >> bot[i];

	MEMSET(dp, -1);
	cout << dfs(0, n-1) << endl;

	return 0;
}