#include<cstdio>
#include<iostream>
using namespace std;
int d[20001],c[20001];
int n;
long long minx=99999999999999;
int main()
{
freopen("bro.in","r",stdin);
freopen("bro.out","w",stdout);
scanf("%d",&n);
for (int i=1; i<=n; ++i)
{
scanf("%d%d",&c[i],&d[i+1]);
d[i+1]+=d[i];
}
for (int i=1; i<=n; ++i)
{
long long ans=0;
for (int j=1; j<i; ++j)
ans+=c[j]*min(d[i]-d[j],d[j]+d[n+1]-d[i]);
for (int j=i+1; j<=n; ++j)
ans+=c[j]*min(d[j]-d[i],d[i]+d[n+1]-d[j]);
minx=min(ans,minx);
}
cout<<minx<<endl;
}