#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define FOR(i,n) for(int i = 0;i<n;i++)
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
typedef pair<pint,int>P1;
typedef vector<vint>vvint;

int dp[2020][2020];
 
signed main() {
    IOS();
    int N;
    cin>>N;
    vint a(N),b(N);
    vpint v(N);
    rep(i,0,N){
        cin>>a[i]>>b[i];
        v[i]={b[i],a[i]};
    }
    sort(all(v));
    reverse(all(v));
    
    rep(i,0,2020)rep(j,0,2020)dp[i][j]=INF;
    dp[0][0]=0;
    rep(i,0,N){
        rep(j,0,N){
            if(dp[i][j]==INF)continue;
            chmin(dp[i+1][j+1],dp[i][j]+v[i].se+v[i].fi*j);
            chmin(dp[i+1][j],dp[i][j]);
        }
    }
    cout<<dp[N][N-N/3]<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}