#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;

int main() {
    int n, top[100], bottom[100], dp[100][100];
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> top[i] >> bottom[i];
    }
    for (int i=1; i<=n; ++i) {
        for (int j=0; j+i-1<n; ++j) {
            dp[j][j+i-1] = INT_MAX;
            if (j == j+i-1) {
                dp[j][j+i-1] = 0;
            } else {
                for (int k=j; k<j+i-1; ++k) {
                    dp[j][j+i-1] = min(dp[j][j+i-1], dp[j][k] + dp[k+1][j+i-1] + top[j] * bottom[k] * top[k+1] * bottom[j+i-1]);
                }
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}