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

struct cell {
	int top, bottom;
};
bool operator<(cell a, cell b) {
	return (a.top!=b.top)? a.top<b.top : a.bottom<b.bottom;
}

int main()
{
	int n, a, b, i;
	int min, cost;
	vector<cell> v;

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

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

	return 0;
}