#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b;
} s[100010];
bool cmp(struct node a, struct node b) { return (a.a - a.b) > (b.a - b.b); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, a, b, i;
  long long int ans = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    s[i].a = a;
    s[i].b = b;
  }
  sort(s, s + n, cmp);
  for (i = 1; i <= n; i++) {
    ans += (long long)s[i - 1].a * (i - 1) + (long long)s[i - 1].b * (n - i);
  }
  cout << ans;
}
