#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct node {
  long long a, b;
} s[maxn];
long long c[maxn];
long long ans, ans1, ans2, ans3;
int main() {
  long long n;
  cin >> n;
  ans = ans1 = ans2 = ans3 = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &s[i].a, &s[i].b);
    c[i] = s[i].a - s[i].b;
    ans1 -= s[i].a;
    ans2 += s[i].b;
  }
  ans2 *= n;
  sort(c + 1, c + n + 1);
  for (long long i = 1; i <= n; i++) {
    ans3 += i * c[n - i + 1];
  }
  ans = ans1 + ans2 + ans3;
  cout << ans;
  return 0;
}
