#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long dp[101][101][101];
long long a[101],b[101];
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	cin >> n;
	rep(i,n) cin >> a[i+1] >> b[i+1];
	
	rep(i,101)rep(j,101)rep(k,101) dp[i][j][k] = INT_MAX;
	for(int j=1;j<=n;j++)
			dp[0][j][j] = 0;
	for(int j=1;j<=n;j++){
		for(int k=1;k<=n;k++){
			if(j != k)dp[1][j][k] = a[j] * b[j] * a[k] * b[k];
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				dp[i][i][k] = min( dp[i][i][k] , dp[i-1][j][k] + a[i] * b[i] * a[j] * b[k] );
				dp[i][k][i] = min( dp[i][k][i] , dp[i-1][j][k] + a[i] * b[i] * a[k] * b[j] );
			}
		}
	}
	long long ans = INT_MAX;
	rep(i,n+1)rep(j,n+1) ans = min(ans,dp[n-1][i][j]);
	cout << ans << endl;
}	