#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dp[100][100], n, a[100], b[100];

int dfs(int l, int r){
  //  printf("%d %d\n", l, r);
  if(l == r) return 0;
  if(dp[l][r] >= 0) return dp[l][r];

  int res = INF;
  REP(i, l, r){
    res = min(res, dfs(l, i) + dfs(i+1, r) + a[l]*b[i]*a[i+1]*b[r]);
  }
  return dp[l][r] = res;
}

int main(){
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  rep(i, n) scanf("%d%d", a+i, b+i);
  printf("%d\n", dfs(0, n-1));
  return 0;
}