#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
#include <valarray>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};

int n;
pair<ll,ll> in[100];
ll dp[100][101];
bool vis[100][101];

ll rec(int a,int b){
  if(a+2>b)return 0;
  if(a+2==b)
    return in[a].F*in[a].S*in[b-1].F*in[b-1].S;
  if(vis[a][b])return dp[a][b];
  vis[a][b]=true;
  ll& ret=dp[a][b]=1LL<<50LL;
  
  for(int s=a+1;s<b;++s)
    ret=min(ret,
            rec(a,s)+rec(s,b)+
            in[a].F*in[s-1].S*in[s].F*in[b-1].S);
  return ret;
}

main(){
  cin>>n;
  rep(i,n)cin>>in[i].F>>in[i].S;

  cout<<rec(0,n)<<endl;
}