#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll sum = 0;
	vector<ll>p;
	for(ll i = 0; i < n; i++){
		ll a,b;
		cin>>a>>b;
		sum = sum - a + (b * n);
		p.push_back(a-b);
	} // Calculate the constant part in sum variable and store the a-b in array.
	
	sort(p.begin(),p.end());reverse(p.begin(),p.end()); // sort them in descending order
	for(ll j=1;j<=n;j++){
		sum = sum + j*p[j-1]; // Now find the variable part sum.
	}
 
	cout<<sum;cout<<"\n";
	
	return 0;
}