#include <bits/stdc++.h>
using namespace std;
int powmod(int x, int y, int m = 1000000007) {
  if (y == 0) return 1;
  int ret = powmod(x, y / 2, m);
  ret = (ret * ret) % m;
  if (y % 2) ret = (ret * x) % m;
  return ret;
}
int product_digits(int n) {
  int product = 1;
  while (n > 0) {
    product *= (n % 10);
    n /= 10;
  }
  return product;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n], b[n];
  long long bsum = 0;
  long long c[n];
  long long g = 1e8;
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    c[i] = a[i] - b[i];
    bsum += b[i];
  }
  long long sum = bsum * (n - 1);
  sort(c, c + n, greater<int>());
  for (long long j = 0; j < n; j++) {
    sum += j * c[j];
  }
  cout << sum << "\n";
  return 0;
}
