#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;

vector<P> v1;
LL dp[2005][1005];

int main(){
	int n;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		v1.push_back(make_pair(b,a));
	}
	sort(v1.rbegin(),v1.rend());
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for(i=0;i<n;i++){
		b=v1[i].first,a=v1[i].second;
		for(j=0;j<=n/3;j++){
			if(dp[i][j]==-1)continue;
				dp[i+1][j+1]=dp[i][j];
			c=dp[i][j]+a+b*(i-j);
			if(dp[i+1][j]==-1 || dp[i+1][j]>c)dp[i+1][j]=c;
		}
	}
	a=dp[n][0];
	for(i=0;i<=n/3;i++){
		if(a>dp[n][i])a=dp[n][i];
	}
	cout<<a<<endl;
	return 0;
}