#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct node {
  long long a, b;
  long long cha;
} p[maxn];
int n;
bool cmp(node x, node y) { return x.cha > y.cha; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &p[i].a, &p[i].b);
    p[i].cha = p[i].a - p[i].b;
  }
  sort(p + 1, p + 1 + n, cmp);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += p[i].a * (i - 1) + (p[i].b * (n - i));
  }
  printf("%lld\n", sum);
  return 0;
}
