#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
using ll = long long;
const int N = 1e5+5;
typedef pair<int,int> pi;
pi q[N];
ll pre[N],nex[N];
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n;cin >> n;
for(int i = 1; i <= n; i++)
cin >> q[i].y >> q[i].x;
sort(q+1,q+n+1);
ll s = 0;
for (int i = 1; i <= n ; i++)
{
pre[i] = pre[i-1];
pre[i] += s * (q[i].x - q[i-1].x);
s += q[i].y;
}
s = 0;
for(int i = n; i >= 1; i--)
{
nex[i] = nex[i+1];
nex[i] += s * (q[i + 1].x - q[i].x);
s += q[i].y;
}
ll res = 1e18;
for (int i = 1; i <= n; i++) res = min(res,pre[i]+nex[i]);
cout << res << '\n';
return 0;
}