#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
using namespace std;
ll dp[110][110],a[110],b[110];
int main(){
  int n;cin>>n;
  lol(i,0,n){
    cin>>a[i]>>b[i];
    lol(j,0,n)dp[i][j]=(1<<30);
  }
  lol(i,0,n)dp[i][i]=0;
  lol(k,1,n){
    lol(i,0,n-k){
      int to=i+k;
      lol(j,i,to){
	dp[i][to]=min(dp[i][to],dp[i][j]+dp[j+1][to]+a[i]*b[j]*a[j+1]*b[to]);
      }
    }
  }
  cout<<dp[0][n-1]<<endl;
  return 0;
}