#include<iostream>#include<cstring>#define ll long longusingnamespacestd;constintMAXN=2000+7;constintMAXC=1E9+7;constintMAXT=MAXN<<1;llf[MAXT];intt[MAXN],v[MAXN];intmain(){intn;cin>>n;intmaxt=0;for(inti=1;i<=n;i++){cin>>t[i]>>v[i];t[i]++;maxt=max(maxt,t[i]);}maxt+=n;memset(f,0x7f,sizeof(f));f[0]=0;for(inti=1;i<=n;i++){for(intj=maxt;j>=t[i];j--){f[j]=min(f[j],f[j-t[i]]+v[i]);}}llans=2e12+7;for(inti=n;i<=maxt;i++){if(f[i]<ans)ans=f[i];}cout<<ans<<endl;return0;}