#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

const int INF = 1 << 29;

int main() {
    int n;
    vector<P> a;

    cin >> n;
    a.resize(n);
    for (int j = 0; j < n; ++j) {
        cin >> a[j].first >> a[j].second;
    }

    int m[105][105];
    for (int j = 0; j < n; ++j) {
        fill(m[j], m[j] + 105, INF);
        m[j][j] = m[j][j+1] = 0;
    }

    for (int j = 2; j <= n; ++j) {
        for (int k = 0; k + j <= n; ++k) {
            for (int l = 1; l < j; ++l) {
                m[k][k+j] = min(m[k][k+j],
                        m[k][k+l] + m[k+l][k+j] + a[k].first * a[k+l-1].second * a[k+l].first * a[k+j-1].second);
            }
        }
    }

    cout << m[0][n] << endl;

    return 0;
}