#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int main() {
  long long n;
  cin >> n;
  unsigned long long ans = 0;
  long long a, b;
  vector<long long> v;
  long long temp = n;
  while (temp--) {
    cin >> a >> b;
    long long temp2 = b;
    b *= n;
    b -= a;
    ans += b;
    v.push_back(a - temp2);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    ans += (v[i]) * (i + 1);
  }
  cout << ans << endl;
  return 0;
}
