#include <bits/stdc++.h>
using namespace std;
long long int a[100005], b[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  set<pair<int, int>> w;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    w.insert({b[i] - a[i], i});
  }
  long long int ans = 0;
  long long int ct = 1;
  for (auto e : w) {
    int i = e.second;
    ans += a[i] * (ct - 1) + b[i] * (n - ct);
    ct++;
  }
  cout << ans << "\n";
  return 0;
}
