#include<iostream>
#include<vector>
using namespace std;

int a[100],b[100];
int n;

int pile(int l,int r){
  int res = 0;
  while(l!=r){
    int pos = l+1;
    for(int i=l+2;i<=r;i++){
      if(b[pos]>b[i])pos = i;
    }
    if(pos != l+1){
      int N = n;
      res += pile(l+1,pos);
      r -= N-n;
    }
    res += a[l]*b[l]*a[l+1]*b[l+1];
    b[l] = b[l+1];
    n--;
    for(int i=l+1;i<n;i++){
      a[i] = a[i+1];
      b[i] = b[i+1];
    }
    r--;    
  }

  return res;
}

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

  cout << pile(0,n-1) << endl;
}