#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

#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()

typedef pair<int,int> pii;
int const INF = 1<<30;
int main() {
  int n;
  cin >> n;
  vector<int> v1(n),v2(n);
  REP(i,n) {
    cin >> v1[i] >> v2[i];
  }
  long long dp[n][n];
  REP(i,n) REP(j,n) dp[i][j] = INF;
  REP(i,n) dp[i][i] = 0;

  for (int i=1; i<n; ++i)
    for (int j=0; j<n-i; ++j)
      for (int k=j; k<j+i; ++k)
        dp[j][j+i] = min(dp[j][j+i], dp[j][k] + dp[k+1][j+i] + v1[j]*v2[k]*v1[k+1]*v2[j+i]);
  cout << dp[0][n-1] << endl;
}