#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, 0, n) {
        cin >> a[i] >> b[i];
    }
    const ll inf = 1LL << 60;
    auto dp = make_v(n, n, inf);
    REP(i, 0, n) {
        dp[i][i] = 0;
    }
    REP(k, 1, n) {
        REP(i, 0, n - k) {
            int r = i + k;
            REP (j, i, r) {
                ll cost = dp[i][j] + dp[j + 1][r] + a[i] * b[j] * a[j + 1] * b[r];
                dp[i][r] = min(dp[i][r], cost);
            }
        }
    }

    cout << dp[0][n - 1] << endl;
    return 0;
}

