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

int main( void )
{
    int n, a, b;
    int CT[101];
    int CD[101];
    int dp[101][101];
    int top[101][101];
    int down[101][101];

    cin >> n;
    for ( int i = 0; i < n; i++ )
    {
        cin >> a >> b;
        CT[i] = a;
        CD[i] = b;
    }

    for ( int i = 0; i+1 < n; i++ )
    {
        dp[0][i]    = CT[i] * CD[i] * CT[i+1] * CD[i+1];
        if ( CT[i] * CD[i+1] < CT[i+1] * CD[i] )
        {
            top[0][i]   = CT[i];
            down[0][i]  = CD[i+1];
        }
        else
        {
            top[0][i]   = CT[i+1];
            down[0][i]  = CD[i];
        }
    }

    for ( int i = 1; i < n; i++ )
    {
        for ( int j = 0; j + i < n; j++ )
        {
            dp[i][j] = dp[i-1][j] + top[i-1][j] * down[i-1][j] * CT[j+i+1] * CD[j+i+1];
            if ( top[i-1][j] * CD[j+i+1] < CT[j+i+1] * down[i-1][j] )
            {
                top[i][j]   = top[i-1][j];
                down[i][j]  = CD[j+i+1];
            }
            else
            {
                top[i][j]   = CT[j+i+1];
                down[i][j]  = down[i-1][j];
            }

            if ( dp[i][j] > dp[i-1][j+1] + top[i-1][j+1] * down[i-1][j+1] * CT[j] * CD[j] )
            {
                dp[i][j] = dp[i-1][j+1] + top[i-1][j+1] * down[i-1][j+1] * CT[j] * CD[j];
                if ( top[i-1][j+1] * CD[j] < CT[j] * down[i-1][j+1] )
                {
                    top[i][j]   = top[i-1][j+1];
                    down[i][j]  = CD[j];
                }
                else
                {
                    top[i][j]   = CT[j];
                    down[i][j]  = down[i-1][j+1];
                }
            }
        }
    }

    cout << dp[n-2][0] << endl;

    return 0;
}