#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 13;
int a[N], b[N], c[N];
int n;
int main() {
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    ans = ans - a[i] + 1ll * b[i] * n;
    c[i] = a[i] - b[i];
  }
  sort(c + 1, c + 1 + n);
  for (int i = 1; i <= n; ++i) ans += (n - i + 1) * 1ll * c[i];
  cout << ans << endl;
}
