#include<bits/stdc++.h>
using namespace std;
typedef long long int Long;
//typedef long long int ll;
typedef int ll;
typedef ll ft;
typedef set< int > si;
typedef long long Long;
typedef vector< int > vi;
typedef vector< vi> vii;
typedef vector< Long> vl;
typedef pair< int ,int > pii;
typedef pair< Long,Long> pll;
typedef pair< string,int > psi;
typedef pair< double ,double > pdd;
#define get getchar_unlocked
#define put putchar_unlocked
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define repstl(i, s) for (__typeof((s).end())i=(s).begin();i!=(s).end();++i)
#define debug1(s,a) cout << s << " " << a << " " << endl;
#define debug2(s,a,b) cout << s << " " << a << " " << b << " " << endl
#define debug3(s,a,b,c) cout << s << " " << a << " " << b << " " << c << " " << endl;
#define debug4(s,a,b,c,d) cout << s << " " << a << " " << b << " " << c << " " << d << " " << endl;
#define debug5(s,a,b,c,d,e) cout << s << " " << a << " " << b << " " << c << " " << d << " " << e << " " << endl;
#define PI 3.1415926535897932384626433832795
#define FO freopen ("out.txt", "w", stdout)
#define FI freopen ("in.txt", "r", stdin)
#define ref(i,a,n) for(int i=a;i<=n;i++)
#define reb(i,n,a) for(int i=n;i>=a;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define gi(n) scanf("%d",&n)
#define gii(n) scanf("%lld",&n)
#define gc(c) scanf(" %c",&c)
#define gs(s) scanf(" %s",s);
#define pi(n) printf("%d",n)
#define pii(n) printf("%lld",n)
#define pc(c) printf("%c",c)
#define ps printf(" ")
#define pn printf("\n")
#define pl(a) printf("%s",a)
#define l(a) 2*a+1
#define r(a) 2*a+2
#define left(a,b) a,(a+b)/2
#define right(a,b) (a+b)/2+1,b
#define mid(a,b) (a+b)/2
void gl( char * str) { register char c= 0 ; register int i= 0 ; while ( c< 33 ) c= get( ) ; while ( c! = '\n ' ) { str[ i] = c; c= get( ) ; i= i+ 1 ; } str[ i] = '\0 ' ; }
void gfi( ft & x) { register ft c = get( ) ; x = 0 ; ft sn= 1 ; for ( ; ( c< 48 || c> 57 ) ; c = get( ) ) if ( c== '-' ) sn= - 1 ; for ( ; c> 47 && c< 58 ; c = get( ) ) { x = ( x<< 1 ) + ( x<< 3 ) + c - 48 ; } x* = sn; }
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
#define MAX 2000000009
#define N 10005
ll n,cap[ N] ,ass[ N] ,dp[ N] [ N] ;
ll solve( ll ind,ll more) {
if ( ind== n && more== 0 ) return 0 ;
if ( ind== n) return MAX;
if ( dp[ ind] [ more] ! = - 1 ) return dp[ ind] [ more] ;
if ( more> 0 ) return dp[ ind] [ more] = min( ass[ ind] + solve( ind+ 1 ,more- 1 ) ,cap[ ind] + solve( ind+ 1 ,more+ 1 ) ) ;
else return dp[ ind] [ more] = cap[ ind] + solve( ind+ 1 ,more+ 1 ) ;
}
int main( ) {
gfi( n) ;
rep( i,n) gfi( ass[ i] ) ,gfi( cap[ i] ) ;
rep( i,n) rep( j,n) dp[ i] [ j] = - 1 ;
pi( cap[ 0 ] + solve( 1 ,1 ) ) ; pn;
return 0 ;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgaW50IExvbmc7Ci8vdHlwZWRlZiBsb25nIGxvbmcgaW50IGxsOwp0eXBlZGVmIGludCBsbDsKdHlwZWRlZiBsbCBmdDsKdHlwZWRlZiBzZXQ8aW50PiBzaTsKdHlwZWRlZiBsb25nIGxvbmcgTG9uZzsKdHlwZWRlZiB2ZWN0b3I8aW50PiB2aTsKdHlwZWRlZiB2ZWN0b3I8dmk+IHZp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