#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20;
int n;
vector<long long> a, b;
void set_up() {
  a.resize(n + 1);
  b.resize(n + 1);
}
bool lf(int i, int j) { return -b[i] + a[i] > -b[j] + a[j]; }
void in() {
  cin >> n;
  set_up();
  int id[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    id[i] = i;
  }
  sort(id + 1, id + n + 1, lf);
  long long ret = 0;
  for (int i = 1; i <= n; i++) {
    ret += a[id[i]] * 1ll * (i - 1) + b[id[i]] * 1ll * (n - i);
  }
  cout << ret;
}
long long ret;
void ou() {}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (fopen("task.inp", "r"))
    freopen("task.inp", "r", stdin), freopen("task.out", "w", stdout);
  ;
  in();
  ou();
}
