#include <bits/stdc++.h>
using namespace std;
bool my_comp(pair<int, int> a, pair<int, int> b) { return (a.first < b.first); }
int main() {
  int i, j, n;
  long long int a, b;
  cin >> n;
  vector<pair<int, int>> ar;
  long long int s_a = 0, s_b = 0, s = 0;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    s_a += a;
    s_b += b;
    ar.push_back(make_pair(a - b, i));
  }
  s = n * s_b;
  s = s - s_a;
  long long int ss = 0;
  sort(ar.begin(), ar.end(), my_comp);
  long long int h;
  for (j = 0; j < n; j++) {
    h = n - j;
    ss += ((ar[j].first) * h);
  }
  s = s + ss;
  cout << s;
  return 0;
}
