#include <bits/stdc++.h>
using namespace std;
const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const long long infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const long double pi = acos(-1.0);
template <typename T1, typename T2>
ostream& operator<<(ostream& cout, const pair<T1, T2>& a) {
  return (cout << "(" << a.first << "; " << a.second << ")");
}
template <typename T>
ostream& operator<<(ostream& cout, const vector<T>& a) {
  if (!a.size()) {
    return (cout << "()");
  }
  cout << "(" << a[0];
  for (int i = 1; i < (int)a.size(); i++) {
    cout << "; " << a[i];
  }
  return (cout << ")");
}
template <typename T>
ostream& operator<<(ostream& cout, const set<T>& a) {
  if (!a.size()) {
    return (cout << "{}");
  }
  auto it = a.begin();
  cout << "{" << *it;
  ++it;
  for (; it != a.end(); ++it) {
    cout << "; " << *it;
  }
  return (cout << "}");
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second - a.first < b.second - b.first;
}
long long n;
pair<long long, long long> a[nmax];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &a[i].first, &a[i].second);
  }
  sort(a, a + n, cmp);
  long long answer = 0;
  for (long long i = 0; i < n; i++) {
    answer += i * a[i].first + (n - i - 1) * a[i].second;
  }
  cout << answer << endl;
  return 0;
}
