#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1LL << 60;
LL a[100], b[100];
LL dp[100][100];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld %lld", &a[i], &b[i]);
	}
	
	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 100; j++){
			dp[i][j] = INF;
		}
		dp[i][i] = 0;
	}
	
	for (int w = 1; w < n; w++){
		for (int l = 0; l + w < n; l++){
			for (int i = l; i <= l + w; i++){
				LL C = a[l] * b[i] * a[i + 1] * b[l + w];
				LL sum = dp[l][i] + dp[i + 1][l + w] + C;
				dp[l][l + w] = min(dp[l][l + w], sum);
			}
		}
	}
	
	printf("%lld\n", dp[0][n - 1]);
	
	return 0;
}