#include <bits/stdc++.h>
using namespace std;
struct DisSatis {
  long long int a, b;
};
bool check(DisSatis i, DisSatis j) { return (i.a - i.b) >= (j.a - j.b); }
long long int find(long long int n, DisSatis *list) {
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    sum += list[i].a * (i + 1 - 1) + list[i].b * (n - i - 1);
  }
  return sum;
}
int main() {
  long long int n, tmpA, tmpB;
  cin >> n;
  long long int index1 = 0, index2 = 0;
  DisSatis *list = new DisSatis[n];
  for (long long int i = 0; i < n; i++) {
    cin >> tmpA >> tmpB;
    list[i].a = tmpA;
    list[i].b = tmpB;
  }
  sort(list, list + n, check);
  cout << find(n, list);
  return 0;
}
