#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b;
  bool operator<(const node &p) const { return (a - b) > (p.a - p.b); }
} a[100005];
int n;
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].a, &a[i].b);
  }
  sort(a + 1, a + 1 + n);
  long long ans = 0;
  for (register int i = 1; i <= n; i++) {
    ans += (long long)a[i].a * (i - 1) + (long long)a[i].b * (n - i);
  }
  cout << ans;
  return 0;
}
