#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, x, y;
  cin >> n;
  vector<tuple<int, int, int, int>> v;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    v.emplace_back(y - x, x, y, i + 1);
  }
  sort(v.begin(), v.end());
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += 1LL * get<1>(v[i]) * i + 1LL * get<2>(v[i]) * (n - i - 1);
  }
  cout << sum;
}
