#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, a, b, ans = 0;
  cin >> n;
  vector<long long int> v;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    ans += b * n - a;
    v.push_back(a - b);
  }
  i = n;
  sort(v.begin(), v.end());
  for (auto it : v) {
    ans += it * i;
    i--;
  }
  cout << ans;
  return 0;
}
