#include<iostream>
#include<cstdio>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
using namespace std;
typedef pair<int,int> ii;
ii p[200];
int n;

void solve()
{
  int M[n+1][n+1];
  rep(i,n+1)rep(j,n+1)M[i][j] = inf;
  rep(i,n+1)M[i][i] = 0;

  rep(j,n)
    {
      rep(i,n-j)
	{
	  REP(k,i+1,i+j+1)
	    {
	      int cost = M[i][k-1] + M[k][i+j] + p[i].first*p[k-1].second*p[k].first*p[i+j].second;
	      if(cost < M[i][i+j])
		{
		  M[i][i+j] = cost;
		  if(i == 0 && i+j == n-1)
		    {
		      //cout << cost << " = M["<<i<<"]["<<k-1<<"] + M["<<k<<"]["<<i+j<<"] + p["<<i<<"].first*p["<<k-1<<"].second*p["<<k<<"].first*p["<<i+j<<"].second" << endl; 
		      //cout <<  M[i][k-1] <<"+"<< M[k][i+j] <<"+"<< p[i].first<<"*"<<p[k-1].second<<"*"<<p[k].first<<"*"<<p[i+j].second;
		      //cout << endl;
		    }
		}
	    }
	}
    }
  cout << M[0][n-1] << endl;
}

int main()
{

  while(cin >> n)
    {
      rep(i,n)cin >> p[i].first >> p[i].second;
      solve();
    }
  return 0;
}