// 100 пъти аз по тебе

#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
const int maxn = 1e5+10;

pair < int, int > p[maxn];
int n;

bool cmp(pair < int, int > a, pair < int, int > b) {

    if (a.second != b.second) return a.second < b.second;
    return a.first < b.first;

}

void solve() {

    int ans = 0, sum = 0, sum2 = 0;

    sort(p+1, p+1+n);
    for (int i = 1 ; i <= n ; ++i) {

        ans += (i-1)*p[i].first*p[i].first - 2*p[i].first*sum + sum2;
        sum += p[i].first;
        sum2 += p[i].first*p[i].first;

    }

    sum = 0;
    sum2 = 0;
    sort(p+1, p+1+n, cmp);
    for (int i = 1 ; i <= n ; ++i) {

        ans += (i-1)*p[i].second*p[i].second - 2*p[i].second*sum + sum2;
        sum += p[i].second;
        sum2 += p[i].second*p[i].second;


    }

    cout << ans << '\n';

}

void read() {

    cin >> n;
    for (int i = 1 ; i <= n ; ++i)
        cin >> p[i].first >> p[i].second;

}

void fast_io() {

    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);

}

signed main () {

    fast_io();
    read();
    solve();

    return 0;

}
