#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 1 <<21
#define P pair<int, int>

int dp(int left, int right);

int n;
vector<P> cost;

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

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