#include <bits/stdc++.h>
using namespace std;
struct st {
  long long a, b, d;
};
bool cmp(st a, st b) {
  if (a.d == b.d) return a.a > b.a;
  return a.d > b.d;
}
int main() {
  long long n;
  cin >> n;
  st stt[n];
  for (int i = 0; i < n; ++i) {
    cin >> stt[i].a >> stt[i].b;
    stt[i].d = stt[i].a - stt[i].b;
  }
  sort(stt, stt + n, cmp);
  long long res = 0;
  for (long long i = 0; i < n; ++i)
    res += stt[i].a * i + stt[i].b * (n - 1 - i);
  cout << res << endl;
}
