#include <bits/stdc++.h>
using namespace std;
int a[102333], b[102333], id[102333], n;
long long ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", a + i, b + i), id[i] = i;
  sort(id + 1, id + n + 1,
       [&](int x, int y) { return a[x] - b[x] > a[y] - b[y]; });
  for (long long i = 1; i <= n; ++i)
    ans += (i - 1) * a[id[i]] + (n - i) * (b[id[i]]);
  printf("%I64d", ans);
  return 0;
}
