#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first - a.second > b.first - b.second;
}
const int maxn = (int)1e5 + 10;
pair<int, int> a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  sort(a, a + n, cmp);
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    ans += a[i].first * 1ll * i + a[i].second * (n - i - 1ll);
  cout << ans << endl;
  return 0;
}
