#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> data;
const ll INF = 1LL <<50;

data dp[200][200][2];

ll mul(data d1, data d2){
  return d1.second.first * d1.second.second * d2.second.first * d2.second.second;
}

P get_minP(data d1, data d2){
  ll a = d1.second.first * d2.second.second;
  ll b = d2.second.first * d1.second.second;
  if(a < b) return P(d1.second.first, d2.second.second);
  else return P(d2.second.first, d1.second.second);
}

int main(){
  int n;
  cin >> n;
  fill(&dp[0][0][0], &dp[199][199][1] + 1, data(INF, P(0, 0)));
  rep(i, n){
    cin >> dp[i][1][0].second.first >> dp[i][1][0].second.second;
    dp[i][1][1].second.first = dp[i][1][0].second.first;
    dp[i][1][1].second.second = dp[i][1][0].second.second;
    dp[i][1][0].first = dp[i][1][1].first= 0;
  }
  for(int i = 2; i <= n; i++){
    for(int j = 0; j <= n - i; j++){
      for(int k = 1; k < i; k++){
	ll cost = dp[j][k][0].first + dp[j+k][i-k][0].first 
	  + mul(dp[j][k][0], dp[j+k][i-k][0]);
	
	P m1 = get_minP(dp[j][k][0], dp[j+k][i-k][1]);
	P m2 = get_minP(dp[j][k][1], dp[j+k][i-k][0]);
	
	if(cost < dp[j][i][0].first || 
	   cost == dp[j][i][0].first && m1.first * m1.second < 
	   dp[j][i][0].second.first * dp[j][i][0].second.second){
	  
	  dp[j][i][0] = dp[j][i][1] = data(cost, m1);
	  
	}else if(cost == dp[j][i][0].first && m1.first * m1.second == 
		 dp[j][i][0].second.first * dp[j][i][0].second.second){
	    
	  if(m1.first < dp[j][i][0].second.first){
	    dp[j][i][0].second = m1;
	  }
	  if(m1.second < dp[j][i][1].second.second){
	    dp[j][i][1].second = m1;
	  }
	    
	  if(cost < dp[j][i][0].first || 
	     cost == dp[j][i][0].first && m2.first * m2.second < 
	     dp[j][i][0].second.first * dp[j][i][0].second.second){
	    
	    dp[j][i][0] = dp[j][i][1] = data(cost, m2);

	  }else if(cost == dp[j][i][0].first && m2.first * m2.second == 
		   dp[j][i][0].second.first * dp[j][i][0].second.second){
	    if(m2.first < dp[j][i][0].second.first){
	      dp[j][i][0].second = m2;
	    }
	    if(m2.second < dp[j][i][1].second.second){
	      dp[j][i][1].second = m2;
	    }
	  } 
	  
	}
      }
      //	cout << dp[j][i][0].first << " " << "i " << i << " j " << j << endl;
    }
  }
  cout << dp[0][n][0].first << endl;
  return 0;
}