#include <algorithm>
#include <climits>
#include <iostream>
#include <utility>

using namespace std;

pair<int, int> cards[100];
int dp[100][100];

int rec(int begin, int end) {
  if (!(dp[begin][end] == -1))
    return dp[begin][end];
  if (begin == end) {
    return dp[begin][end] = 0;
  }
  int m = INT_MAX;
  for (int i = begin; i < end; i++)
    m = min(m, cards[begin].first * cards[i].second
             * cards[i+1].first * cards[end].second
             + rec(begin, i) + rec(i+1, end));
  return dp[begin][end] = m;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> cards[i].first >> cards[i].second;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      dp[i][j] = -1;
  cout << rec(0, n-1) << endl;
  return 0;
}