#include <bits/stdc++.h>
using namespace std;
int n;
int a[100000], b[100000], c[100000];
bool cmp(int i, int j) { return (a[i] - b[i] > a[j] - b[j]); }
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    c[i] = i;
  }
  sort(c, c + n, cmp);
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += (long long)(a[c[i]] - b[c[i]]) * (i + 1) + (long long)b[c[i]] * n -
           a[c[i]];
  }
  cout << res;
}
