#include <iostream>
#include <vector>
#include <map>

using namespace std;

vector<pair<int, int> > cards;

main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int a, b;
    cin >> a >> b;
    cards.push_back(make_pair(a, b));
  }
  int ans = 0;
  while(cards.size() > 1){
    //cout << ans << endl;
    /*for(int i=0;i<cards.size();i++){
      cout << cards[i].first << ' ' << cards[i].second << endl;
      }cout << endl;*/
    int fmax = 0, smax = 0;
    int pf, ps;
    for(int i=0;i<cards.size();i++){
      if(fmax < cards[i].first){
	fmax = cards[i].first;
	pf = i;
      }else if(fmax == cards[i].first && cards[pf].second > cards[i].second){
	pf = i;
      }
      if(smax < cards[i].second){
	smax = cards[i].second;
	ps = i;
      }else if(smax == cards[i].second && cards[ps].first > cards[i].first){
	ps = i;
      }
    }
    if(pf == ps){
      if(cards[pf].first > cards[ps].second){
	smax = 0;
	for(int i=0;i<cards.size();i++){
	  if(i == pf) continue;
	  if(smax < cards[i].second){
	    smax = cards[i].second;
	    ps = i;
	  }else if(smax == cards[i].second && cards[ps].first > cards[i].first){
	    ps = i;
	  }
	}
      }else if(cards[pf].first < cards[ps].second){
	fmax = 0;
	for(int i=0;i<cards.size();i++){
	  if(i == ps) continue;
	  if(fmax < cards[i].first){
	    fmax = cards[i].first;
	    pf = i;
	  }else if(fmax == cards[i].first && cards[pf].second > cards[i].second){
	    pf = i;
	  }
	}
      }else{
	int ffmax = 0;
	int ssmax = 0;
	int pff, pss;
	for(int i=0;i<cards.size();i++){
	  if(i == pf || i == ps) continue;
	  if(ffmax < cards[i].first){
	    ffmax = cards[i].first;
	    pff = i;
	  }else if(ffmax == cards[i].first && cards[pff].second > cards[i].second){
	    pff = i;
	  }
	  if(ssmax < cards[i].second){
	    ssmax = cards[i].second;
	    pss = i;
	  }else if(ssmax == cards[i].second && cards[pss].first > cards[i].first){
	    pss = i;
	  }
	}
	if(ffmax >= ssmax){
	  fmax = ffmax;
	  pf = pff;
	}else if(ffmax < ssmax){
	  smax = ssmax;
	  ps = pss;
	}
      }
    }
    vector<pair<int, int> >::iterator ite = cards.begin();
    int a = cards[ps].first, b = cards[pf].second;
    ans += fmax * b * a * smax;
    //cout << "========= " << a << ' ' << b << endl;
    if(pf < ps){
      cards[ps] = make_pair(a, b);
      for(int i=0;i<pf;i++) ++ite;
      cards.erase(ite);
    }else{
      cards[pf] = make_pair(a, b);
      for(int i=0;i<ps;i++) ++ite;
      cards.erase(ite);
    }
  }
  cout << ans << endl;
  return 0;
}