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