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

int u[100], b[100];
int dp[100][100];

int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> u[i] >> b[i];
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i != j) dp[i][j] = INT_MAX;
    }
    dp[i][i] = 0;
  }

  for(int i = 1; i <= n; i++){
    for(int j = 0; j < n - i; j++){
      for(int k = j; k < j + i; k++){
        dp[j][j+i] = min(dp[j][j+i], dp[j][k] + dp[k+1][j+i] + u[j] * b[k] * u[k+1] * b[j+i]);
      }
    }
  }

  cout << dp[0][n-1] << endl;
  return 0;
}