#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;cin>>n;
  std::vector<int> a(n),b(n);
  for(int i=0;i<n;i++) cin>>a[i]>>b[i];
  ll dp[n+1][n+1];
  for(int i=0;i<n;i++)for(int j=0;j<n;j++) dp[i][j]=INF;
  for(int i=0;i<n;i++) dp[i][i]=0;
  for(int k=1;k<=n-1;k++){
      for(int i=0;i+k<n;i++){
          for(int j=i;j<i+k;j++){
              ll cost=a[i]*b[j]*a[j+1]*b[i+k];
              dp[i][i+k]=min(dp[i][i+k],dp[i][j]+dp[j+1][i+k]+cost);
          }
      }
  }
  cout<<dp[0][n-1]<<endl;
}