#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
vector<pair<long long, pair<long long, long long> > > v;
int main() {
  int n;
  cin >> n;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    v.push_back({a - b, {a, b}});
  }
  sort(v.begin(), v.end());
  long long kiri = 0;
  for (int i = v.size() - 1; i >= 0; i--) {
    res += v[i].second.first * (kiri) + v[i].second.second * (n - 1 - kiri);
    kiri++;
  }
  cout << res << endl;
  return 0;
}
