#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long z = 1000000000;
const long long N = 1e9 + 1;
const long long INF = 1e18;
long long mod2 = 998244353;
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
long long t, n, m;
bool cmp(const pair<long long, long long>& a,
         const pair<long long, long long>& b) {
  return (a.first - a.second > b.first - b.second);
}
void solve() {
  cin >> n;
  vector<pair<long long, long long>> a;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    a.push_back(make_pair(x, y));
  }
  sort((a).begin(), (a).end(), cmp);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans += (i)*a[i].first + (n - i - 1) * a[i].second;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  t = 1;
  while (t--) {
    solve();
  }
}
