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

int n, dp[MAX_N][MAX_N];
vector<P> cards, cardsCpy;
bool useFlag[MAX_N];

void setDp();
void loop(int left, int right);
void disp();
void dispCards();
void resetUseFlag();

int main(){
    resetUseFlag();
    cards.clear();
    cin >>n;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >>x >>y;
        cards.push_back( make_pair(x, y) );
    }
    cardsCpy = cards;
    setDp();
    loop(0, n - 1);
    cout <<dp[0][n - 1] <<endl;
    return 0;
}

void setDp(){
    for(int i = 0; i < MAX_N; i++){
        for(int j = 0; j < MAX_N; j++){
            if(i == j) dp[i][j] = 0;
            else dp[i][j] = INF;
        }
    }
}

/*int loop(int left, int right, int deep){
    for(int i = left; i < right; i++){
        cards[i].first = cardsCpy[i].first;
        useFlag[left] = false;
        if(right != (left + 1)) loop(i, i + 1, deep + 1);
        cout <<i <<", " <<i + 1 <<", " <<deep <<endl;
        if(!useFlag[i]){
            cout <<"!cal" <<endl;
            int nowCost = cards[i].first * cards[i].second * cards[i + 1].first * cards[i + 1].second + dp[left][i] + dp[i + 1][right];
            cout <<"left = " <<left <<" i = " <<i <<" right = " <<right <<" " <<cards[i].first <<" * " <<cards[i].second <<" * " <<cards[i].first <<" * " <<cards[i].second <<" + " <<dp[left][i] << " + " <<dp[i + 1][right] <<endl;
            cout <<"nowCost = " <<nowCost <<endl;
            if(nowCost < dp[left][right]){
                cout <<"! dp[" <<left <<"][" <<right <<"]" <<endl;
                dp[right][left] = nowCost;
            }
            cards[i + 1].first = cards[i].first;
            useFlag[i] = true;
            cout <<"useFlag[" <<i <<"] = true" <<endl;
            dispCards();
            cout <<endl;
        }
    }
    return dp[left][right];
}*/


void loop(int left, int right){
    for(int i = left; i < right; i++){
        cards[i + 1].first = cardsCpy[i + 1].first;
        //cout <<"! " <<i + 1 <<endl;
        loop(left, i);
        loop(i + 1, right);
        int tmp = cards[left].first * cards[left].second * cards[right].first * cards[right].second + dp[left][i] + dp[i + 1][right];
        //cout <<cards[left].first <<" * " <<cards[left].second <<" * " <<cards[right].first <<" * " <<cards[right].second <<" + " <<dp[left][i] <<" + " <<dp[i + 1][right] <<" = " <<tmp <<endl;
        if(dp[left][right] > tmp) dp[left][right] = tmp;
        cards[i + 1].first = cards[i].first;
    }
    //cout <<left <<", " <<right <<", " <<dp[left][right] <<endl;
    //dispCards();
    //disp();
    //cout <<endl;
}


void disp(){
    for(int i= 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout <<dp[i][j] <<" ";
        }
        cout <<endl;
    }
}

void dispCards(){
    for(int i = 0; i < cards.size(); i++){
        cout <<"(" <<cards[i].first <<", " <<cards[i].second <<") ";
    }
    cout <<endl;
}

void resetUseFlag(){
    for(int i = 0; i < MAX_N; i++) useFlag[i] = false;
}