#include <bits/stdc++.h>
using namespace std;
struct nn {
  long long int a;
  long long int b;
  long long int c;
} nn[100005];
bool cmp(struct nn x, struct nn y) { return x.c > y.c; }
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%lld %lld", &nn[i].a, &nn[i].b);
      nn[i].c = nn[i].a - nn[i].b;
    }
    sort(nn, nn + n, cmp);
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += nn[i].a * i + nn[i].b * (n - i - 1);
    }
    printf("%lld\n", sum);
  }
  return 0;
}
