#include <bits/stdc++.h>
struct Interval {
  long long first;
  long long second;
};
bool compareInterval(Interval i1, Interval i2) {
  return i1.first - i1.second > i2.first - i2.second;
}
using namespace std;
int main() {
  int n;
  long long sum = 0;
  cin >> n;
  vector<Interval> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    cin >> a[i].second;
  }
  sort(a.begin(), a.end(), compareInterval);
  long long tmp1 = n;
  for (int i = 0; i < n; i++) {
    long long tmp2 = i;
    sum += a[i].first * tmp2 + a[i].second * (tmp1 - tmp2 - 1);
  }
  cout << sum;
}
