#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  int a[110], b[110];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  const int INF = 1 << 30;
  int dp[110][110];
  fill_n((int*)dp, 110 * 110, INF);
  for (int w = 0; w < n; w++) {
    for (int i = 0; i + w < n; i++) {
      int j = i + w;
      if (w == 0) {
        dp[i][j] = 0;
      } else {
        for (int k = i; k < j; k++) {
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + a[i] * b[k] * a[k + 1] * b[j]);
        }
      }
    }
  }
  cout << dp[0][n - 1] << endl;

  return 0;
}
