#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n], b[n], c[n], s1 = 0, s2 = 0, s3 = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    s1 = s1 + a[i];
    s2 = s2 + (b[i] * n);
    c[i] = a[i] - b[i];
  }
  sort(c, c + n, greater<long long>());
  for (long long i = 1; i <= n; i++) s3 = s3 + (i * c[i - 1]);
  cout << -s1 + s2 + s3;
}
