#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll a[111],b[111],dp[111][111];

ll rec(int l,int r){
    if(dp[l][r]!=0)return dp[l][r];
    if(l==r)return 0;
    if(l+1==r)return dp[l][r]=a[l]*b[l]*a[r]*b[r];
    ll ret=longinf;
    REP(i,l,r){
        ret=min(rec(l,i)+rec(i+1,r)+a[l]*b[i]*a[i+1]*b[r],ret);
    }
    return dp[l][r]=ret;
}

int main(){
    int n;cin>>n;
    rep(i,n)cin>>a[i]>>b[i];
    cout<<rec(0,n-1)<<endl;
    return 0;
}
