#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> tos[1000009];
vector<pair<int, int> > qqq;
int as[1000009];
int bs[1000009];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> as[i] >> bs[i];
    qqq.push_back(make_pair(bs[i] - as[i], i));
  }
  sort(qqq.begin(), qqq.end());
  long long wyn = 0;
  for (int i = 0; i < n; ++i) {
    wyn += 1LL * as[qqq[i].second] * i + 1LL * bs[qqq[i].second] * (n - i - 1);
  }
  cout << wyn << endl;
  return 0;
}
