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