#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  long long a1 = a.first, a2 = a.second;
  long long b1 = b.first, b2 = b.second;
  return a1 - a2 > b1 - b2;
}
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < n; i++) {
    long long u, w;
    cin >> u >> w;
    v.push_back({u, w});
  }
  sort(v.begin(), v.end(), comp);
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += i * v[i].first + (n - i - 1) * v[i].second;
  }
  cout << sum << endl;
  return 0;
}
