#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<long long int, long long int>& lhs,
         const pair<long long int, long long int>& rhs) {
  return (lhs.first - lhs.second) > (rhs.first - rhs.second);
}
int main() {
  int n;
  cin >> n;
  vector<pair<long long int, long long int> > st(n);
  for (auto& p : st) {
    cin >> p.first >> p.second;
  }
  sort(st.begin(), st.end(), cmp);
  long long int cost = 0;
  long long int left = 0;
  long long int right = n - 1;
  for (auto& p : st) {
    cost += (p.first * left) + (p.second * right);
    ++left;
    --right;
  }
  cout << cost << endl;
  return 0;
}
