#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long res = 0;
  int n;
  cin >> n;
  vector<long long> dif(n);
  vector<pair<long long, long long>> ab(n);
  for (int i = (0); i < n; i++) {
    cin >> ab[i].first >> ab[i].second;
    dif[i] = ab[i].first - ab[i].second;
    res += (1LL * n * ab[i].second - ab[i].first);
  }
  sort(dif.rbegin(), dif.rend());
  for (int i = (0); i < n; i++) res += 1LL * dif[i] * (i + 1);
  cout << res << "\n";
}
