#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int cards[100][2];
	for (int i = 0; i < n; ++i)
		scanf("%d %d", &cards[i][0], &cards[i][1]);

	bool used[100];
	memset(used, 0, sizeof(used));
	int sum = 0;
	for (int left = n; left > 1; --left)
	{
		vector<int> canUse;
		for (int i = 0; i < n; ++i)
			if (!used[i])
				canUse.push_back(i);
		int put;
		int putted;
		pair<int, int> mini(INT_MAX, INT_MAX);
		for (int i = 1; i < canUse.size(); ++i)
		{
			int a = canUse[i-1];
			int b = canUse[i];
			pair<int, int> t(cards[a][0]*cards[b][1]
			, cards[a][0]*cards[a][1]*cards[b][0]*cards[b][1]);

			if (t < mini)
			{
				mini = t;
				put = a;
				putted = b;
			}
		}
		used[put] = true;
		cards[putted][0] = cards[put][0];
		sum += mini.second;
	}
	printf("%d\n", sum);

	return 0;
}