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