#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

int a[101], b[101];

//??????dp
int dp[101][101] = {};
int dfs(int l, int r) {
	if (dp[l][r] != INF)return dp[l][r];
	if (r - l == 1)
		dp[l][r] = 0;
	else if (r - l == 2)
		dp[l][r] = a[l] * b[l] * a[l + 1] * b[l + 1];
	else if (r - l >= 3)
		rep(m, l + 1, r) dp[l][r] = min(dp[l][r], dfs(l, m) + dfs(m, r) + a[l] * b[m - 1] * a[m] * b[r - 1]);
	return dp[l][r];
}

signed main() {
	memset(dp, 0x3f, sizeof(dp));
	int n; cin >> n;
	rep(i, 0, n)cin >> a[i] >> b[i];
	cout << dfs(0, n) << endl;
	return 0;
}