#include<iostream>
#include<algorithm>
using namespace std;

int main(){
  int n;
  int a[100],b[100];
  long long dp[101][101];

  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i] >> b[i];

  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++)dp[i][j] = 1e10;
  }

  for(int i=0;i<n;i++)dp[i][i+1] = 0;

  for(int len = 1;len<=n;len++){
    for(int l=0;l+len<=n;l++){
      int r = l + len;
      for(int m=l+1;m<r;m++){
	dp[l][r] = min(dp[l][r], dp[l][m] + dp[m][r] + a[l]*b[m-1]*a[m]*b[r-1]);
      }
    }
  }

  cout << dp[0][n] << endl;
}