#include <stdio.h>

#define INF 0x100000000

int n;
int u[100];
int d[100];
long long int dp[100][100]; // dp[l][r]

int main() {
    int i,j,k;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        for (j=0; j<n; j++) {
	    dp[i][j] = INF;
	}
    }

    for (i=0; i<n; i++) {
        int a, b;
	scanf("%d %d", &a, &b);
        u[i] = a;
	d[i] = b;
	dp[i][i] = 0;
    }

    for (k=1; k<n; k++) {
        for (i=0; i<n-k; i++) {
	    for (j=0; j<k; j++) {
	        int l1 = i;
		int r1 = i+j;
		int l2 = i+j+1;
		int r2 = i+k;
	        long long int val = dp[l1][r1] + dp[l2][r2] + u[l1] * d[r1] * u[l2] * d[r2];
		if (val < dp[l1][r2]) dp[l1][r2] = val;
	    }
	}
    }

    printf("%lld\n", dp[0][n-1]);
}