#include <bits/stdc++.h>
using namespace std;
inline void in(int &n) {
  n = 0;
  int ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
  }
  n = n * sign;
}
int a[100005];
int b[100005];
int tmpA[100005];
int tmpB[100005];
void mergeIt(int start, int mid, int stop) {
  int low1 = start;
  int up1 = mid;
  int low2 = mid + 1;
  int up2 = stop;
  int totalPos = stop - start + 1;
  int currPos = 1;
  while (low1 <= up1 && low2 <= up2) {
    long long int a1 = a[low1];
    long long int b1 = b[low1];
    long long int a2 = a[low2];
    long long int b2 = b[low2];
    long long int first = a1 * (currPos - 1) + b1 * (totalPos - currPos) +
                          a2 * (currPos + 1 - 1) +
                          b2 * (totalPos - currPos - 1);
    long long int second = a2 * (currPos - 1) + b2 * (totalPos - currPos) +
                           a1 * (currPos + 1 - 1) +
                           b1 * (totalPos - currPos - 1);
    if (first <= second) {
      tmpA[currPos] = a1;
      tmpB[currPos] = b1;
      low1++;
    } else {
      tmpA[currPos] = a2;
      tmpB[currPos] = b2;
      low2++;
    }
    currPos++;
  }
  while (low1 <= up1) {
    int a1 = a[low1];
    int b1 = b[low1];
    tmpA[currPos] = a1;
    tmpB[currPos] = b1;
    low1++;
    currPos++;
  }
  while (low2 <= up2) {
    int a2 = a[low2];
    int b2 = b[low2];
    tmpA[currPos] = a2;
    tmpB[currPos] = b2;
    low2++;
    currPos++;
  }
  currPos = 1;
  for (int i = start; i <= stop; i++) {
    a[i] = tmpA[currPos];
    b[i] = tmpB[currPos];
    currPos++;
  }
  return;
}
void merge_sort(int start, int stop) {
  if (start == stop) {
    return;
  }
  int mid = (start + stop) / 2;
  merge_sort(start, mid);
  merge_sort(mid + 1, stop);
  mergeIt(start, mid, stop);
}
int main() {
  int n;
  in(n);
  for (int i = 1; i <= n; i++) {
    in(a[i]);
    in(b[i]);
  }
  merge_sort(1, n);
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    long long int x = a[i];
    x = x * (i - 1);
    long long int y = b[i];
    y = y * (n - i);
    ans += x + y;
  }
  printf("%I64d\n", ans);
  return 0;
}
