#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int INF = 1<<29;

int main()
{
	int n;
	scanf("%d", &n);
	
	vector<pii> cards(n);
	rep(i, n){
		scanf("%d%d", &cards[i].first, &cards[i].second);
	}
	
	vvi dp(n+1, vi(n));
	rep(j, n)
		dp[1][j] = 0;
	
	reep(i, 2, n+1){
		rep(j, n-i+1){
			dp[i][j] = INF;
			reep(k, 1, i){
				int cost = cards[j].first * cards[j+k-1].second * cards[j+k].first * cards[j+i-1].second;
				dp[i][j] = min(dp[i][j], dp[k][j] + dp[i-k][j+k] + cost);
			}
		}
	}
	
	printf("%d\n", dp[n][0]);
	
	return 0;
}