#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 7;
void solve() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > arr(n);
  for (long long i = 0; i < (n); i++) cin >> arr[i].first >> arr[i].second;
  sort(arr.begin(), arr.end(),
       [](pair<long long, long long> a, pair<long long, long long> b) {
         return (a.first - a.second) < (b.first - b.second);
       });
  long long res = 0;
  for (long long i = 0; i < (n); i++) {
    res += (arr[i].first * (n - i - 1) + arr[i].second * (i));
  }
  cout << res << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) solve();
}
