#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  return (a.first > b.first);
}
int main() {
  int n;
  cin >> n;
  long long int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin >> b[i];
  }
  vector<pair<long long int, long long int> > vec;
  for (int i = 0; i < n; i++) {
    vec.push_back(make_pair((a[i] - b[i]), i));
  }
  sort(vec.begin(), vec.end(), comp);
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[vec[i].second] * i + b[vec[i].second] * (n - i - 1);
  }
  cout << ans;
}
