#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
pair<int, int> a[N];
bool cmp(pair<int, int> first, pair<int, int> second) {
  return first.second + second.first < first.first + second.second;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].first, &a[i].second);
  sort(a + 1, a + n + 1, cmp);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += 1LL * (i - 1) * a[i].first + 1LL * (n - i) * a[i].second;
  }
  cout << ans << endl;
  return 0;
}
