#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

int main(){
	int n,minimum,tmp;
	scanf("%d",&n);
	int table[n][n];
	int data[n][2];

	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++)table[i][k] = 0;
		scanf("%d %d",&data[i][0],&data[i][1]);
	}

	for(int col = 0; col <= n-2; col++){
		table[1][col] = data[col][0]*data[col][1]*data[col+1][0]*data[col+1][1];
	}

	for(int row = 2; row <= n-1; row++){
		for(int col = 0; col <= n-(row+1); col++){
			minimum = 2147483647;

			for(int div = 0; div <= row-1;div++){
				tmp = (table[div][col]+table[row-div-1][col+div+1])+(data[col][0]*data[col+div][1]*data[col+div+1][0]*data[col+row][1]);
				minimum = min(minimum,tmp);
			}
			table[row][col] = minimum;
		}
	}

	printf("%d\n",table[n-1][0]);

    return 0;
}