#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int ans = INF;

void dfs(int cost, vector< pair<int, int> > v) {
//	REP(i, v.size()) cout << cost << ' ' << v[i].first << ' ' << v[i].second << endl;
//	cout << endl;
	if(v.size() == 1)
		ans = min(ans, cost);
	REP(i, v.size()-1) {
		vector< pair<int, int> > v2(v);
//		cout << v2[i].first << ' ' << v2[i+1].first << endl;
		int cost2 = cost + v2[i].first * v2[i].second * v2[i+1].first * v2[i+1].second;
		v2[i].second = v2[i+1].second;
		v2.erase(v2.begin()+ i + 1);
		dfs(cost2, v2);
	}
	return;
}

int main() {
	int n; cin >> n;
	vector< pair<int, int> > cards(n);
	REP(i, n)
		cin >> cards[i].first >> cards[i].second;
	dfs(0, cards);
	cout << ans << endl;
	return 0;
}