#include <bits/stdc++.h>
using namespace std;
long long n;
pair<int, int> arr[101010];
bool cmp(pair<int, int> &a, pair<int, int> &b) {
  return (a.first - a.second) - (b.first - b.second) > 0;
}
int main() {
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld%lld", &arr[i].first, &arr[i].second);
  }
  sort(arr, arr + n, cmp);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans += (long long)arr[i].first * i + arr[i].second * (n - i - 1);
  }
  printf("%lld", ans);
}
