#include <iostream>
#include <list>
using namespace std;

typedef pair<unsigned int, unsigned int> puiui;

#define fi first
#define se second

int main() {
	int n;
	list<puiui> cards;
	cin >> n;
	for(int i = 0; i < n; i++) {
		unsigned int a, b;
		cin >> a >> b;
		cards.push_back(puiui(a,b));
	}

	unsigned int cost = 0;
	while(cards.size() > 1) {
		list<puiui>::iterator it;
		unsigned int maximum = 0;
		for(list<puiui>::iterator i = cards.begin(); i != cards.end(); i++) {
			if(maximum < ((i == cards.begin()) ? 0 : i->fi)) {
				maximum = i->fi;
				it = i;
				it--;
			}
			list<puiui>::iterator nexti = i; nexti++;
			if(maximum < ((nexti == cards.end()) ? 0 : i->se)) {
				maximum = i->se;
				it = i;
			}
		}

		list<puiui>::iterator tmp = it;
		tmp++;
		cost += it->fi * it->se * tmp->fi * tmp->se;
		it->se = tmp->se;
		cards.erase(tmp);
	}

	cout << cost << endl;
}