#include <bits/stdc++.h>
using namespace std;
const long long INF64 = 1000000000000000000;
const long long BigPrime = 252097800623;
const long double LDINF = 1000000000000;
const long long Mmod = 998244353;
const long long INF = 1000000000;
const long long Mod = 1000000007;
const long double PI = acosl(-1.);
const long double Eps = 10e-10;
const long long Prime = 31;
const unsigned int N = 100005;
pair<long long, long long> aa[N];
int n;
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> aa[i].first >> aa[i].second;
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first - b.first + b.second - a.second > 0;
}
void solve() {
  sort(aa, aa + n, cmp);
  long long ans = 0;
  for (int i = 0; i < n; i++)
    ans += aa[i].first * i + aa[i].second * (n - i - 1);
  cout << ans << endl;
}
int main() {
  int testcases = 1;
  for (int _ = 0; _ < testcases; ++_) {
    input();
    solve();
  }
  return 0;
}
