#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1ll << 35;
int a[100], b[100];
ll dp[100][100];
ll rec(int x, int y){
  if(x == y) return 0;
  if(~dp[x][y]) return dp[x][y];
  ll ret = INF;
  for(int i = x; i < y; i++){
    ret = min( ret, rec( x, i) + rec( i + 1, y) + a[x] * b[i] * a[i + 1] * b[y]);
  }
  return dp[x][y] = ret;
}

int main(){
  int n;
  cin >> n;
  fill_n( *dp, 100 * 100, -1);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  cout << rec( 0, n - 1) << endl;
}