#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
const long long N = 1e5 + 7;
const long long inf = 8e18 + 7;
const int mod = 998244353;
long long n;
struct node {
  long long a, b;
  bool operator<(const node& A) const {
    if (a >= b && A.a >= A.b) {
      long long k = max(a, b) - min(a, b);
      long long q = max(A.a, A.b) - min(A.a, A.b);
      return k > q;
    } else if (a <= b && A.a <= A.b) {
      long long k = max(a, b) - min(a, b);
      long long q = max(A.a, A.b) - min(A.a, A.b);
      return k < q;
    } else
      return a >= b;
  }
} tmp[N];
int main() {
  cin >> n;
  for (long long i = 1, u = 1, v = 1; i <= n; i++) cin >> tmp[i].a >> tmp[i].b;
  sort(tmp + 1, tmp + 1 + n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += (i - 1) * tmp[i].a + (n - i) * tmp[i].b;
  cout << ans << "\n";
  return 0;
}
