#include <iostream>
#include <climits>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n, dp[100][100] = {}, c[100][2];
	cin >> n;
	rep(i,n) {
		cin >> c[i][0] >> c[i][1];
	}
	rep(i,100) {
		rep(j,100) {
			if(i==j) continue;
			dp[i][j] = INT_MAX;
		}
	}
	rep2(i,1,n) {
		rep(j,n-i) {
			rep2(k,j,j+i) {
				dp[j][j+i] = min(dp[j][j+i], dp[j][k]+dp[k+1][j+i]+c[j][0]*c[k][1]*c[k+1][0]*c[j+i][1]);
			}
		}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}