#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int a[100];
int b[100];
int memo[100][100];

int solve(int pos, int num){
  int ret = INT_MAX;
  if(num == 1) return 0;
  if(memo[pos][num]) return memo[pos][num];
  REP(i,num-1){
    int t = pos + i;
    int cost = solve(pos,i+1) + solve(pos+i+1,num-i-1);
    cost += a[pos] * b[t] * a[t+1] * b[pos+num-1];
    ret = min(ret, cost);
  }
  return memo[pos][num] = ret;
}

int main(){
  int n;
  scanf("%d",&n);
  REP(i,n) scanf("%d%d",&a[i],&b[i]);
  printf("%d\n",solve(0,n));
  return 0;
}