#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;

#define REP(i, n) for ((i) = 0; (i) < (int)(n); ++(i))
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int MAX = 110;
const ll INF = 1LL<<50;
int n;
int h[MAX], l[MAX];
ll dp[MAX][MAX];

int main() {
    while (cin >> n) {
        int i, j, k, b;

        for (i = 0; i < n; ++i) cin >> h[i] >> l[i];
        for (i = 0; i < MAX; ++i) for (j = 0; j < MAX; ++j) dp[i][j] = INF;
        
        for (i = 0; i < n; ++i) {
            dp[i][i+1] = 0;
            dp[i][i+2] = h[i] * l[i] * h[i+1] * l[i+1];
        }
        for (b = 3; b <= n; ++b) {
            for (i = 0; i + b <= n; ++i) {
                j = i+b;
                for (k = i+1; k+1 <= j; ++k) {
                    chmin(dp[i][j], dp[i][k] + dp[k][j] + h[i] * l[k-1] * h[k] * l[j-1]);
                }
            }
        }
        
        cout << dp[0][n] << endl;
    }
    
    return 0;
}
