#include <bits/stdc++.h>
using namespace std;
struct people {
  int a, b;
};
bool cmp1(people A, people B) { return A.a - A.b > B.a - B.b; }
people p[100010];
long long ans = 0;
long long tmp = 0;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p[i].a, &p[i].b);
  }
  sort(p + 1, p + 1 + n, cmp1);
  for (int i = 1; i <= n; i++) {
    ans += (1LL * (i - 1) * p[i].a + 1LL * (n - i) * p[i].b);
  }
  printf("%lld\n", ans);
}
