#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second - a.first < b.second - b.first;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, i, j, a, b;
  cin >> n;
  vector<pair<int, int> > v;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    v.push_back({a, b});
  }
  sort(v.begin(), v.end(), cmp);
  long long bty = 0LL;
  for (i = 0; i < n; i++) {
    bty += ((1LL * (n - i - 1) * v[i].second) + (1LL * i * v[i].first));
  }
  cout << bty << endl;
  return 0;
}
