#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP((i),0,(n))
#define RREP(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rrep(i,n) RREP(i,n,0)
#define each(it,X) for(__typeof((X).begin())  it=(X).begin();it!=(X).end();it++)
#define all(v) ((v).begin(),(v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int,int>pr;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef set<int>si;
const int INF=1000000000000000ll;
const int mod=1000000007ll;

int n,a[100],b[100];
int dp[100][100];
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);

    cin>>n;rep(i,n)cin>>a[i]>>b[i];
    fill_n(*dp,10000,INF);
    rep(i,n)dp[i][i]=0;

    REP(i,1,n){
        for(int j=0;j+i<n;j++){
            ///[j,j+i]
            int mi=INF;
            for(int k=j;k<j+i;k++){
                int cost=dp[j][k]+dp[k+1][i+j];
                cost+=a[j]*b[k]*a[k+1]*b[i+j];
                mi=min(mi,cost);
            }
            dp[j][j+i]=mi;
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}