#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
struct node {
  long long x, y;
  bool operator<(const node& a) const { return x - y > a.x - a.y; }
} e[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> e[i].x >> e[i].y;
  sort(e, e + n);
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += e[i].x * i + e[i].y * (n - i - 1);
  cout << ans << endl;
}
