#include <bits/stdc++.h>
using namespace std;
long long n, mux1, mux2, ans1, ans2;
pair<long long, long long> a[100005];
bool fcmp1(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first != b.first) return (a.first > b.first);
  return (a.second < b.second);
}
bool fcmp2(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second != b.second) return (a.second < b.second);
  return (a.first > b.first);
}
bool fcmp(pair<long long, long long> a, pair<long long, long long> b) {
  return ((a.first - a.second) > (b.first - b.second));
}
void vivod() {
  for (int i = 1; i <= n; i++) cout << a[i].first << " ";
  cout << '\n';
  for (int i = 1; i <= n; i++) cout << a[i].second << " ";
  cout << '\n';
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a + 1, a + n + 1, fcmp);
  for (int i = 1; i <= n; i++)
    ans2 += (a[i].first * (i - 1) + a[i].second * (n - i));
  cout << ans2;
  return 0;
}
