#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<climits>
using namespace std;

#define TOP 0
#define BOTTOM 1

int main()
{
	int n, a, b, i;
	int min, cost;
	int v[100][2];
	vector<int> order;

	cin>>n;
	order.resize(n);
	for (i = 0; i < n; i++) {
		cin>>a>>b;
		v[i][0] = a;
		v[i][1] = b;
		order[i]=i;
	}

	min = INT_MAX;
	do {
		cost = 0;
		for (i = 0; i < n-1; i++)
			cost += v[order[0]][TOP]*v[order[i]][BOTTOM] * v[order[i+1]][TOP]*v[order[i+1]][BOTTOM];
		if (min > cost) min = cost;
	} while (next_permutation(order.begin(), order.end()));
	cout<<min<<endl;

	return 0;
}