#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100100;
long long n;
long long a[maxn], b[maxn];
long long I[maxn];
long long ans;
bool cmp(long long i, long long j) { return a[i] - b[i] > a[j] - b[j]; }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (long long i = 0; i < n; i++) I[i] = i;
  sort(I, I + n, cmp);
  for (long long i = 0; i < n; i++) ans += a[I[i]] * i + b[I[i]] * (n - 1 - i);
  cout << ans << endl;
  return 0;
}
