#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
inline int GA(long long n, vector<long long> &vec) {
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    vec.push_back(x);
  }
  return 0;
}
inline int GAEG(long long m, vector<long long> vec[]) {
  for (int i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  return 0;
}
const long long MD = 1000000007;
bool isvalid(long long xx, long long yy, long long n, long long m) {
  return (xx >= 0 && xx < n && yy >= 0 && yy < m);
}
long long pw(long long x, long long y, long long dr) {
  if (y == 0) return 1;
  long long o = y / 2;
  long long f = pw(x, o, dr) % dr;
  if (y % 2) {
    return (((f * f) % dr) * x) % dr;
  } else
    return (f * f) % dr;
}
bool cmp(const pair<long long, long long> &a,
         const pair<long long, long long> &b) {
  if (a.first < a.second && b.first < b.second) return a.first > b.first;
  if (a.first > a.second && b.first > b.second) return a.second < b.second;
  return a.second < b.second;
}
vector<pair<long long, pair<long long, long long> > > v;
int main() {
  long long n;
  cin >> n;
  long long cnt = 0;
  for (int i = 0; i < n; ++i) {
    long long x, y;
    cin >> x >> y;
    cnt += (n * y - x);
    v.push_back(make_pair(x - y, make_pair(x, y)));
  }
  sort(v.begin(), v.end(),
       greater<pair<long long, pair<long long, long long> > >());
  for (int i = 0; i < n; ++i) {
    long long a = v[i].second.first;
    long long b = v[i].second.second;
    cnt += ((i + 1) * (a - b));
  }
  cout << cnt << endl;
}
