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

int main() {
    int n, a, b;
    cin >> n;
    vector<pair<int,int> > v;
    for (int i=0; i<n; ++i) {
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    int cost = 0;
    while (1 < (int)v.size()) {
        int up, down, max_cost = 0;
        for (int i=0; i<(int)v.size(); ++i) {
            for (int j=0; j<(int)v.size(); ++j) {
                if (i == j) continue;
                if (max_cost < v[i].second * v[j].first) {
                    max_cost = v[i].second * v[j].first;
                    up = i;
                    down = j;
                }

            }
        }
        cost += v[up].first * v[up].second * v[down].first * v[down].second;
        v.push_back(make_pair(v[up].first, v[down].second));
        v.erase(v.begin() + max(up, down));
        v.erase(v.begin() + min(up, down));
    }
    cout << cost << endl;
    return 0;
}