#include <bits/stdc++.h>
const int inf = INT_MAX;
const int MAX = 1e5 + 8;
const long long MOD = 1e9 + 7;
const int TOT_PRIMES = 1e6 + 9;
const int MAX_A = 71;
const int LN = 20;
using namespace std;
bool prime[MAX];
void precompute() {
  memset(prime, false, sizeof(prime));
  for (int i = 2; i < MAX; i++) {
    if (!prime[i]) {
      for (int j = 2 * i; j < MAX; j += i) prime[j] = true;
    }
  }
}
int a[60][60], b[60][60];
int main() {
  int n;
  vector<long long> dif;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    dif.push_back(x - y);
    ans = ans + (n * y - x);
  }
  sort(dif.begin(), dif.end());
  for (int i = n - 1; i >= 0; i--) {
    ans = ans + (dif[n - i - 1] * (i + 1));
  }
  cout << ans;
}
