#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> A(n), B(n);
    vector<vector<ll>> dp(n, vector<ll>(n+1, INF<ll>));
    for (int i = 0; i < n; ++i) {
        cin >> A[i] >> B[i];
        dp[i][i+1] = 0;
    }
    for (int len = 2; len <= n; ++len) {
        for (int i = 0, j = len; j <= n; ++i, ++j) {
            for (int k = 1; k < j; ++k) {
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]+A[i]*B[k-1]*A[k]*B[j-1]);
            }
        }
    }
    cout << dp[0][n] << "\n";
    return 0;
}
