#include <bits/stdc++.h>
using namespace std;
long long nMod = 1e9 + 7;
inline long long GCD(long long a, long long b) {
  while (b != 0) {
    long long c = a % b;
    a = b;
    b = c;
  }
  return a;
};
inline long long LCM(long long a, long long b) { return (a / GCD(a, b)) * b; };
vector<pair<long long, pair<long long, long long> > > arr;
int n;
void vietnakid() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    arr.push_back({a - b, {a, b}});
  }
  sort(arr.begin(), arr.end(),
       greater<pair<long long, pair<long long, long long> > >());
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += i * arr[i].second.first + (n - i - 1) * arr[i].second.second;
  }
  cout << res << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  vietnakid();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
