#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, nn, ans = 0;
  cin >> n;
  nn = n;
  vector<long long> v;
  while (n--) {
    long long q, a;
    cin >> q >> a;
    v.push_back(q - a);
    ans += -q + (a * nn);
  }
  sort(v.rbegin(), v.rend());
  for (int i = 1; i <= nn; ++i) {
    ans += i * v[i - 1];
  }
  cout << ans;
  return 0;
}
