#include <bits/stdc++.h>
using namespace std;
const long long N = 5e2 + 9, oo = 1e9;
void solve() {
  long long n, x = 0, y = 0;
  cin >> n;
  vector<pair<long long, pair<long long, long long>>> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i].second.first >> a[i].second.second;
    a[i].first = a[i].second.second - a[i].second.first;
  }
  sort(a.begin(), a.end());
  for (long long i = 0; i < n; i++) {
    x += a[i].second.first * i + (n - i - 1) * a[i].second.second;
  }
  cout << x << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) solve();
}
