#include <bits/stdc++.h>
using namespace std;
long long n, ans;
pair<long long, long long> a[100005];
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first - a.second) > (b.first - b.second);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    ans += a[i].first * (i - 1);
    ans += a[i].second * (n - i);
  }
  cout << ans;
}
