#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
#define INF INT_MAX
#define P pair<int, int>
#define N 101

int loop(int left, int right);
void resetDp();

int n;
vector<P> cost;
int dp[N][N];

int main(){
    resetDp();
    cin >>n;
    for(int i = 0; i < n; i++){
        int top, bottom;
        cin >>top >>bottom;
        cost.push_back( make_pair(top, bottom) );
    }
    cout <<loop(0, n - 1) <<endl;
    return 0;
}

int loop(int left, int right){
    if(left == right) return 0;
    else if(dp[left][right] != -1) return dp[left][right];
    else {
        int ret = INF;
        for(int i = left; i < right; i++){
            ret = min(ret, loop(left, i) + loop(i + 1, right) + (cost[left].first * cost[i].second * cost[i + 1].first * cost[right].second));
        }
        return dp[left][right] = ret;
    }
}

void resetDp(){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            dp[i][j] = INF;
        }
    }
}