#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005];
vector<pair<long long, long long> > dif;
void solve() {
  long long n;
  cin >> n;
  long long tot = 0;
  for (long long i = 1; i < n + 1; i++) {
    cin >> a[i] >> b[i];
    tot += a[i] * (i - 1) + b[i] * (n - i);
    dif.push_back({abs(b[i] - a[i]), i});
  }
  sort((dif).begin(), (dif).end()), reverse((dif).begin(), (dif).end());
  long long left = 1, right = n;
  for (auto i : dif) {
    long long pos = i.second, del = i.first;
    if (a[pos] > b[pos]) {
      tot += (-del) * (pos - left);
      left++;
    } else {
      tot += (-del) * (right - pos);
      right--;
    }
  }
  cout << tot;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
