#include <bits/stdc++.h>
using namespace std;
int64_t A[100006], B[100006], V[100006];
bool com(int a, int b) { return A[a] - B[a] > A[b] - B[b]; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    V[i] = i;
  }
  sort(V, V + N, com);
  int64_t ans = 0;
  for (int i = 0; i < N; i++) {
    int64_t a = A[V[i]], b = B[V[i]];
    ans += a * i + b * (N - i - 1);
  }
  cout << ans;
}
