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

struct card{
	int top, bottom;
};

int main(){
	int n;
	unsigned int cost = 0;
	vector<card> cards;
	cin >> n;
	for(int i = 0; i < n; i++){
		card c;
		cin >> c.top >> c.bottom; 
		cards.push_back(c);
	}
	while(cards.size() != 1){
		int t, b;
		int nmax = -1;
		for(int i = 0; i < cards.size(); i++){
			for(int j = 0; i < cards.size(); i++){
				if(i != j){
					if(cards[i].bottom * cards[j].top > nmax){
						nmax = cards[i].bottom * cards[j].top;
						t = i;
						b = j;
					}
				}
			}
		}
		cost += cards[t].top * cards[t].bottom * cards[b].top * cards[b].bottom;
		cards[t].bottom = cards[b].bottom;
		cards[b] = cards[cards.size() - 1];
		cards.pop_back();
	}
	cout << cost << endl;
	return 0;
}