#include <bits/stdc++.h>
using namespace std;
const int inf = (int)2e9;
const long long md = 1000000007;
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < (int)n; i++) cin >> v[i].first >> v[i].second;
  sort((v).begin(), (v).end(), [&](pair<int, int>& a, pair<int, int>& b) {
    return (a.second - a.first) < (b.second - b.first);
  });
  long long ans = 0;
  for (int i = 0; i < (int)n; i++) {
    ans += (v[i].first) * (i + 1 - 1ll) + (v[i].second) * (n - i - 1 + 0ll);
  }
  cout << ans;
}
