#include <bits/stdc++.h>
using namespace std;
class TT {
 public:
  long long int a, b, c;
};
bool compare(TT o1, TT o2) {
  if (o1.a > o2.a) {
    return 1;
  } else
    return 0;
}
int main() {
  int n;
  cin >> n;
  vector<pair<long long int, long long int> > vec;
  for (long long int i = 0; i < n; i++) {
    pair<long long int, long long int> pp;
    cin >> pp.first >> pp.second;
    vec.push_back(pp);
  }
  vector<long long int> v;
  vector<TT> abhi;
  for (long long int i = 0; i < n; i++) {
    TT obj;
    obj.a = vec[i].first - vec[i].second;
    obj.b = vec[i].first;
    obj.c = vec[i].second;
    abhi.push_back(obj);
  }
  sort(abhi.begin(), abhi.end(), compare);
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    ans += (abhi[i].b * (i));
    ans += (abhi[i].c * (n - 1 - i));
  }
  cout << ans << endl;
}
