#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123456;
const int MAXINT = 2147483098;
const long long MAXLL = 9223372036854775258LL;
long long a[MAXN], b[MAXN];
vector<int> pos;
bool comp(int i, int j) { return a[i] - b[i] > a[j] - b[j]; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    pos.push_back(i);
  }
  sort(pos.begin(), pos.end(), comp);
  long long ans = 0;
  for (int i = 0; i < pos.size(); ++i) {
    ans += a[pos[i]] * i + b[pos[i]] * (n - i - 1);
  }
  cout << ans << '\n';
  return 0;
}
