#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e7 + 9, MAXN = 1e6, INF = 2 * 1e9;
bool comp(pair<int, int> a, pair<int, int> b) {
  return a.first - a.second > b.first - b.second;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > v(n, {0, 0});
  for (pair<int, int> &p : v) {
    cin >> p.first >> p.second;
  }
  sort(v.begin(), v.end(), comp);
  unsigned long long int ans = 0;
  for (int i = 0; i < v.size(); ++i) {
    ans += ((unsigned long long int)v[i].first * (unsigned long long int)i) +
           ((unsigned long long int)v[i].second *
            (unsigned long long int)(n - 1 - i));
  }
  cout << ans << endl;
  return 0;
}
