#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int s[10100],v[10100],d[10100],n,sum;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>v[i]>>d[i];
sum+=d[i];
s[i]=s[i-1]+d[i-1];
}
int maxx=0x3f3f3f3f;
for(int i=1;i<=n;i++){
int t=0;
for(int j=1;j<=n;j++){
if(i==j) continue;
int q=abs(s[j]-s[i]);
int dis=min(q,sum-q);
t+=dis*v[j];
}
if(t<=maxx) maxx=t;
}
cout<<maxx<<endl;
return 0;
}