#include <iostream>
#include <algorithm>

#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i) ++)

using namespace std;

int main() {
  int n, a[110], b[110];
  cin >> n;
  rep(i, 0, n) {
    cin >> a[i] >> b[i];
  }

  int dp[110][110];
  rep(i, 0, 110) {
    rep(j, 0, 110) {
      dp[i][j] = 2<<29;
    }
  }

  for(int len = 1; len <= n; len ++) {
    if(len == 1) {
      for(int p = 0; p < n; p ++) {
	dp[p][p+1] = 0;
      }
    }
    else {
      for(int p = 0; p <= n; p ++) {
	int r = p + len;
	if(r > n) continue;

	for(int q = p + 1; q < r; q ++) {
	  dp[p][r] = min(dp[p][r], dp[p][q] + dp[q][r] + a[p]*b[q-1]*a[q]*b[r-1]);
	}
      }
    }
  }

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

  return 0;
}