#include <bits/stdc++.h>
using namespace std;
int x[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int y[] = {-1, 0, 1, -1, 1, -1, 0, -1};
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);
vector<pair<int, int>> vec;
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first != b.first) return a < b;
  return (a.second > b.second);
}
long long arr[N], brr[N], crr[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i] >> brr[i];
    crr[i] = arr[i] - brr[i];
    ans += (n * brr[i]) - arr[i];
  }
  sort(crr, crr + n, greater<long long>());
  for (int i = 0; i < n; i++) {
    ans += crr[i] * (i + 1);
  }
  cout << ans;
  return 0;
}
