#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define N 11000
using namespace std;
int n;
long long ans=1e18,maxl,s[N],w[N];
long long read()
{
long long x=0,f=1; char ch=getchar();
while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1; ch=getchar();}
while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘; ch=getchar();}
return x*f;
}
int main()
{
n=read();
for(int i=1;i<=n;i++)
{
s[i]=read(),w[i]=read();
maxl+=w[i];
w[i]+=w[i-1];
}
for(int k=1;k<=n;k++)
{
long long tot=0;
for(int i=1;i<=n;i++)
{
int x=k,y=i;
if(x>y) swap(x,y);
tot+=min(w[y-1]-w[x-1],maxl-(w[y-1]-w[x-1]))*s[i];
}
ans=min(ans,tot);
}
printf("%lld",ans);
return 0;
}