#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (auto(i) = (0); (i) < (n); (i)++) cin >> a[i] >> b[i];
  vector<pair<long long, int> > c(n);
  for (auto(i) = (0); (i) < (n); (i)++) {
    c[i] = make_pair(b[i] - a[i], i);
  }
  sort((c).begin(), (c).end());
  long long r = 0;
  for (auto(i) = (0); (i) < (n); (i)++) {
    r +=
        (long long)a[c[i].second] * i + (long long)(n - i - 1) * b[c[i].second];
  }
  cout << r;
  return 0;
}
