#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > v(n);
  for (auto &x : v) scanf("%d%d", &x.first, &x.second);
  sort(v.begin(), v.end(),
       [&](const pair<int, int> &a, const pair<int, int> &b) {
         return a.second + b.first < a.first + b.second;
       });
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    res += (long long)i * v[i].first;
    res += (long long)(n - i - 1) * v[i].second;
  }
  cout << res << endl;
  return 0;
}
