#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > arr(n), brr(n);
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i].second >> arr[i].first;
    brr[i].second = i;
    brr[i].first = arr[i].second - arr[i].first;
  }
  sort(brr.begin(), brr.end());
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    long long int x = brr[i].second;
    sum += arr[x].first * n - arr[x].second +
           (n - i) * (arr[x].second - arr[x].first);
  }
  cout << sum << endl;
  return 0;
}
