#include <iostream>

using namespace std;

#define MN 100
#define INF (1<<28)

int n;
int P[MN][2];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        P[i][0] = a;
        P[i][1] = b;
    }
    int dp[n][n]; // from, to, cost
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) {
                dp[i][j] = 0;
            } else {
                dp[i][j] = INF;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j + i < n; j++) {
            for (int k = j; k < j + i; k++) {
                dp[j][j+i] = min(dp[j][j+i], dp[j][k] + dp[k+1][j+i] + P[j][0] * P[k][1] * P[k+1][0] * P[j+i][1]);
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}