#include <bits/stdc++.h>
using namespace std;
struct ds {
  long long x, y;
};
const long long N = 1e5 + 1;
long long n;
ds a[N];
bool cmp(ds u, ds v) { return (u.x - u.y) > (v.x - v.y); }
int main() {
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> a[i].x >> a[i].y;
  sort(a + 1, a + n + 1, cmp);
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) ans += a[i].x * (i - 1) + a[i].y * (n - i);
  cout << ans;
  return 0;
}
