#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<unsigned long long> v(n);
    unsigned long long ans = 0;
    for (int i = 0; i < n; i++) {
      unsigned long long a, b;
      cin >> a >> b;
      ans += (n * b - a);
      v[i] = (a - b);
    }
    sort(v.begin(), v.end(), greater<int>());
    for (int i = 0; i < n; i++) ans += (v[i] * (i + 1));
    cout << ans << endl;
  }
  return 0;
}
