#include <bits/stdc++.h>
using namespace std;
struct Node {
  int a;
  int b;
} student[100005];
int cha[100005];
int main() {
  memset(cha, 0, sizeof(cha));
  int n;
  long long res = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &student[i].a, &student[i].b);
    cha[i] = student[i].a - student[i].b;
    res = res + (long long)student[i].b * n - (long long)student[i].a;
  }
  sort(cha + 1, cha + n + 1);
  for (int i = n; i >= 1; i--) {
    res += (long long)cha[i] * (n - i + 1);
  }
  printf("%lld\n", res);
  return 0;
}
