#include <bits/stdc++.h>
int in() {
  int x = 0;
  char c = getchar();
  bool f = false;
  while (c < '0' || c > '9') f |= c == '-', c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return f ? -x : x;
}
long long lin() {
  long long x = 0;
  char c = getchar();
  bool f = false;
  while (c < '0' || c > '9') f |= c == '-', c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return f ? -x : x;
}
const int N = 1e5 + 5;
struct node {
  long long a, b;
  inline bool operator<(const node &x) const {
    return (this->a - this->b) > (x.a - x.b);
  }
} s[N];
long long res;
int main() {
  int n = in();
  for (int i = 1; i <= n; ++i) s[i] = (node){lin(), lin()};
  std::sort(s + 1, s + 1 + n);
  for (int i = 1; i <= n; ++i)
    res += (long long)s[i].b * n + (s[i].a - s[i].b) * i - s[i].a;
  printf("%lld\n", res);
  return 0;
}
