#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, int> > v;
int n;
long long A[100005];
long long B[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    A[i] = (long long)a;
    B[i] = (long long)b;
    v.push_back(make_pair((long long)(b - a), i));
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long a = A[v[i - 1].second];
    long long b = B[v[i - 1].second];
    ans += a * ((long long)(i - 1)) + b * ((long long)(n - i));
  }
  printf("%lld\n", ans);
  return 0;
}
