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

int n, dp[MAX_N][MAX_N];
vector<P> cards, cardsCpy;
bool useFlag[MAX_N];
map<P, int> toM;
int m[MAX_N_P][MAX_N_P];
vector<P> vec;

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

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();
    setToM();
    setM();
    P tmp, tmp2;
    //while(cin >>tmp.first >>tmp.second >>tmp2.first >>tmp2.second) cout <<m[ toM[tmp] ][ toM[tmp2] ] <<endl;
    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;
        }
    }
}

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;
        if(left != i) loop(left, i);
        if(i + 1 != right) loop(i + 1, right);
        int tmp = m[ toM[ cards[left] ] ][ toM[ cards[right] ] ] + dp[left][i] + dp[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;
}

void setToM(){
    int cnt = 0;
    for(int i = 0; i < cards.size(); i++){
        for(int j = i; j < cards.size(); j++){
            P tmp;
            tmp.first = cards[i].first;
            tmp.second = cards[j].second;
            toM.insert( map<P, int>::value_type(tmp, cnt) );
            cnt++;
            vec.push_back(tmp);
        }
    }
}

void setM(){
    for(int i = 0; i < vec.size(); i++){
        for(int j = i; j < vec.size(); j++){
            if(i == j){
                m[i][j] = 0;
            } else{
                m[i][j] = vec[i].first * vec[i].second * vec[j].first * vec[j].second;
            }
        }
    }
}