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