#include <iostream>
#include <vector>
using namespace std;

typedef pair <int, int> PII;
typedef vector <PII> VPII;
typedef long long LL;
const int NONE = -1;
int n;
VPII P;
LL memo[101][101];

LL solve( int l, int r ) {
    if ( memo[l][r] != NONE ) return memo[l][r];
    if ( l == r ) return memo[l][r] = 0;
    LL res = 1LL<<60;
    for ( int i = l; i < r; ++ i ) {
        res = min( res, solve( l, i ) + solve( i + 1, r ) + P[l].first * P[i].second * P[i+1].first * P[r].second );
    }
    return memo[l][r] = res;
}

int main() {
    cin >> n;
    P = VPII(n);
    for ( int i = 0; i < n; ++ i ) {
        cin >> P[i].first >> P[i].second;
    }
    for ( int i = 0; i < n; ++ i ) {
        for ( int j = 0; j < n; ++ j ) {
            memo[i][j] = NONE;
        }
    }
    cout << solve( 0, n - 1 ) << endl;
    return 0;
}