#include <bits/stdc++.h>
using namespace std;
constexpr int IINF = INT_MAX;

int n, a[105], b[105], dp[105][105];

int rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(r==l) return 0;

    int res = IINF;
    for(int i=l;i<r;i++){
        res = min(res, rec(l,i)+rec(i+1,r)+a[l]*b[i]*a[i+1]*b[r]);
    }
    return dp[l][r] = res;
}

int main() {
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<n;i++) fill(dp[i], dp[i]+n, -1);
    cout << rec(0,n-1) << endl;
    return 0;
}
