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