#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n], b[n];
  vector<pair<long long int, long long int>> diff;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    diff.push_back({a[i] - b[i], i});
  }
  sort(diff.rbegin(), diff.rend());
  long long int diss = 0;
  for (int i = 1; i <= n; i++) {
    diss += diff[i - 1].first * i + b[diff[i - 1].second] * n -
            a[diff[i - 1].second];
  }
  cout << diss << endl;
}
