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

int main() {
  int n;
  int a[100], b[100];
  int dp[100][100];
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> a[i] >> b[i];
  }
  if (n == 1) {
    cout << 0 << endl;
  } else {
    for (int i=0; i<n; i++) {
      dp[0][i] = 0;
    }
    for (int i=1; i<n; i++) {
      for (int j=0; j<n; j++) {
        dp[i][j] = INT_MAX;
      }
    }
    for (int i=1; i<n; i++) {
      for (int j=0; j<n-i; j++) {
        for (int k=0; k<i; k++) {
          dp[i][j] = min(dp[i][j], dp[k][j]+dp[i-k-1][j+k+1]+a[j]*b[j+k]*a[j+k+1]*b[i+j]);
        }
      }
    }
    cout << dp[n-1][0] << endl;
  }
  return 0;
}