#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
long long qpow(long long x, long long k) {
  return k == 0 ? 1 : 1ll * qpow(1ll * x * x % M, k >> 1) * (k & 1 ? x : 1) % M;
}
const int maxn = 1e5 + 5;
int a[maxn], b[maxn];
vector<pair<int, pair<int, int> > > v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < n; i++) v.push_back({(b[i] - a[i]), {a[i], b[i]}});
  sort(v.begin(), v.end());
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long aa = v[i].second.first;
    long long bb = v[i].second.second;
    sum += (i * aa + bb * (n - i - 1));
  }
  cout << sum << endl;
}
