#include <bits/stdc++.h>
using namespace std;
const int N = 100004;
long long w[N];
int main() {
  long long a, b, ans = 0;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld %lld", &a, &b);
    ans += b * n - a;
    w[i] = a - b;
  }
  sort(w + 1, w + n + 1, greater<long long>());
  for (int i = 1; i <= n; i++) ans += w[i] * i;
  printf("%lld\n", ans);
}
