#include <bits/stdc++.h>
using namespace std;
bool op(pair<int, int> &x, pair<int, int> &y) {
  return (x.first - x.second > y.first - y.second);
}
int main() {
  int n;
  long long cnt = 0;
  pair<int, int> p[100005];
  cin >> n;
  n--;
  for (int i = 0; i <= n; i++) cin >> p[i].first >> p[i].second;
  sort(p, p + n + 1, op);
  for (int i = 0; i <= n; i++)
    cnt += 1LL * i * p[i].first + 1LL * (n - i) * p[i].second;
  cout << cnt << "\n";
  return 0;
}
