#include <bits/stdc++.h>
using namespace std;
long long int n;
vector<pair<long long int, long long int> > v;
bool cmp(pair<long long int, long long int> p1,
         pair<long long int, long long int> p2) {
  if (p1.second + p2.first < p1.first + p2.second) return true;
  return false;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end(), cmp);
  long long int res = 0;
  for (int i = 0; i < n; i++) {
    res += 1LL * v[i].first * i + 1LL * v[i].second * (n - i - 1);
  }
  cout << res << endl;
}
