#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> v;
  long long n, i, j, k, l, s = 0, a, b;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    s = s + (n * b) - a;
    v.push_back(a - b);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (i = 0; i < v.size(); i++) {
    s += (v[i] * (i + 1));
  }
  cout << s;
}
