#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct cmp {
  bool operator()(const pair<ll, ll>& a, const pair<ll, ll>& b) {
    return abs(a.first - a.second) > abs(b.first - b.second);
  }
};
int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> v(n);
  multiset<pair<ll, ll>, cmp> s;
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    s.insert(v[i]);
  }
  int l = 0;
  int r = n - 1;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    pair<ll, ll> cur = *s.begin();
    s.erase(s.begin());
    if (cur.first <= cur.second) {
      ans += cur.first * r + cur.second * (n - 1 - r);
      r--;
    } else {
      ans += cur.first * l + cur.second * (n - 1 - l);
      l++;
    }
  }
  cout << ans;
  return 0;
}
