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

#define DEBUG(x) cerr << #x << " = " << x << endl

int N;
int top[100], bottom[100];
int dp[100][100];

int solve(int s, int e) {
  //cerr << "solve(" << s << "," << e << ")" << endl;
  int &res = dp[s][e];
  if(res != -1) return res;
  if(e - s == 1) return 0;
  res = numeric_limits<int>::max();
  for(int i = s + 1; i <= e - 1; ++i) {
    res = min(res, solve(s, i) + solve(i, e) + top[s]*bottom[i-1]*top[i]*bottom[e-1]);
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> top[i] >> bottom[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(0, N) << endl;
}