#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;

int main(){
	int N, C[100][2], dp[100][100];
	cin >> N;
	for(int i = 0; i < N; i++) cin >> C[i][0] >> C[i][1];
	for(int i = 2; i <= N; i++){
		for(int j = 0; j + i - 1 < N; j++){
			int *dp_p = &dp[j][j + i - 1];
			*dp_p = INT_MAX;
			for(int k = j; k < j + i - 1; k++){
				*dp_p = min( *dp_p, 
					dp[j][k] + dp[k+1][j+i-1]
					+ C[j][0]*C[k][1]*C[k+1][0]*C[j+i-1][1] );
			}
		}
	}
	printf("%d\n", dp[0][N-1] );
	return 0;
}