#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll fpow(ll b, ll p) {
  if (p == 0) return 1;
  ll h = fpow(b, p / 2);
  if (p % 2) return h * b % (ll)(1e12) * h % (ll)(1e12);
  return h * h % (ll)(1e12);
}
bool cmp(pii a, pii b) { return a.first - a.second > b.first - b.second; }
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<pii> v(n);
  for (auto &i : v) cin >> i.first >> i.second;
  sort(v.begin(), v.end(), cmp);
  ll ans = 0;
  for (ll i = 0; i <= n - 1; i++) {
    ans += v[i].first * i + v[i].second * (n - i - 1);
  }
  cout << ans << "\n";
  return 0;
}
