#include <iostream>
#include <vector>
#include <climits>
#include <iomanip>

using namespace std;

long long dp[101][101];
vector<pair<int, int> > cards;
int n;

/*void print_table(){
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(dp[i][j] == INT_MAX){
	cout << "INF";
      }else{
	cout << setw(3) << dp[i][j];
      }
      cout << ' ';
    }
    cout << endl;
  }
  cout << endl;
  }*/

main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int a, b;
    cin >> a >> b;
    cards.push_back(make_pair(a, b));
  }
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      dp[i][j] = INT_MAX;
    }
    dp[i][i] = 0;
  }
  //print_table();
  for(int i=1;i<n;i++){
    for(int j=0;j<=n-i;j++){
      for(int k=j;k<j+i;k++){
	//cout << cards[j].first << ' ' << cards[k].second << ' ' << cards[k+1].first << ' ' << cards[j+i].second << endl;
        long long cost = cards[j].first * cards[k].second * cards[k+1].first * cards[j+i].second;
        dp[j][j+i] = min(dp[j][j+i],cost+dp[j][k]+dp[k+1][j+i]);
	//print_table();
      }
    }
  }
  cout<< dp[0][n-1] <<endl;
  return 0;
}