#include <bits/stdc++.h>
using namespace std;
const long long MX5 = 2 * 1e5 + 3;
const long long MX9 = 2 * 1e9 + 3;
pair<long long, long long> A[MX5], ansi[MX5];
int main() {
  long long n, ans = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    pair<long long, long long> p;
    cin >> p.first >> p.second;
    A[i] = p;
    p.first = p.first - p.second;
    p.second = i;
    ansi[i] = p;
  }
  long long ii = 0;
  sort(ansi, ansi + n);
  for (long long i = n - 1; i >= 0; i--) {
    ans += (A[ansi[i].second].first) * (ii);
    ans += (A[ansi[i].second].second) * (n - 1 - ii);
    ii++;
  }
  cout << ans;
  return 0;
}
