#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using iil = pair<ll, ll>;
using vi = vector<int>;
const int MAXN = 5 + 100000;
int n;
iil arr[MAXN];
bool cmp1(const iil& p, const iil& q) {
  if ((p.first - p.second) == (q.first - q.second)) {
    return p.second < q.second;
  }
  return (p.first - p.second) > (q.first - q.second);
}
bool cmp2(const iil& p, const iil& q) {
  if (p.second == q.second) {
    return (p.first - p.second) > (q.first - q.second);
  }
  return p.second < q.second;
}
ll val(const iil& p, int i) {
  return (1LL * p.first * i) + (1LL * p.second * (n - i - 1));
}
ll get() {
  ll ans = 0LL;
  for (int i = (int)0; i < (int)n; ++i) {
    ans += val(arr[i], i);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  vector<iil> l, r;
  for (int i = (int)0; i < (int)n; ++i) {
    cin >> arr[i].first >> arr[i].second;
  }
  ll ans = get();
  sort(arr, arr + n, cmp1);
  ans = min(ans, get());
  sort(arr, arr + n, cmp2);
  ans = min(ans, get());
  cout << ans << '\n';
  return 0;
}
