#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

#define F first
#define S second

using namespace std;

typedef pair<int,int> P;
const int MAX = 101;
int N;
vector<P> V;

int dp[MAX][MAX];

int rec(int l, int r){

  if(dp[l][r] != -1) return dp[l][r];
  if(l+1 == r) return dp[l][r] = V[l].F*V[l].S*V[r].F*V[r].S;
  if(l == r) return dp[l][r] = 0;

  for(int c = l; c < r; c++){
    if(dp[l][r] == -1) dp[l][r] = rec(l,c)+rec(c+1,r)+V[l].F*V[c].S*V[c+1].F*V[r].S;
    else dp[l][r] = min(dp[l][r], rec(l,c)+rec(c+1,r)+V[l].F*V[c].S*V[c+1].F*V[r].S);
  }
  return dp[l][r];
}

int main(){
  memset(dp,-1,sizeof(dp));
  cin >> N;
  V.resize(N);
  for(int i = 0; i < N; i++) cin >> V[i].first >> V[i].second;
  cout << rec(0,N-1) << endl;
  return 0;
}