#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll loops")
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
bool cmp(pair<long long int, long long int> a,
         pair<long long int, long long int> b) {
  if (a.first > b.first)
    return 1;
  else if (a.first == b.first && a.second < b.second)
    return 1;
  else
    return 0;
}
bool cmp2(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.first < b.first)
    return 1;
  else if (a.first == b.first && a.second > b.second)
    return 1;
  else
    return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> v(n);
  long long int sum = 0;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> v[i].first;
    cin >> v[i].second;
    a[i] = v[i].first - v[i].second;
    sum += v[i].second * n - v[i].first;
  }
  sort(a.begin(), a.end(), greater<int>());
  ;
  for (long long int i = 0; i < n; i++) {
    sum += a[i] * (i + 1);
  }
  cout << sum << "\n";
  return 0;
}
