#include <bits/stdc++.h>
using namespace std;
bool myCompare(pair<long long int, long long int> a,
               pair<long long int, long long int> b) {
  return a.first - a.second > b.first - b.second;
}
void code() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > v(n);
  for (long long int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end(), myCompare);
  long long int curr = 0, ans = 0;
  for (long long int i = 0; i < v.size(); i++) {
    curr++;
    ans += (curr - 1) * v[i].first + (n - curr) * v[i].second;
  }
  cout << ans;
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int tc = 1;
  while (tc--) {
    code();
  }
  return 0;
}
