#include <bits/stdc++.h>   using namespace std;   long long int dp[2010][2010];   long long int a[2010];   long long int b[2010];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i] >> b[i];     }     for (int i = 0; i <= 2000; i++) {       for (int j = 0; j <= 2000; j++) {         dp[i][j] = 10000000000000000;       }     }     dp[0][0] = 0;     for (int i = 1; i <= n; i++) {       long long int o = a[i] + 1;       for (int j = 0; j <= n; j++) {         o = a[i] + 1;         if (j == 0) {           dp[i][j] = 0;         }         if (o >= j) {           o = j;         }         if (j >= o) {           dp[i][j] = min(b[i] + dp[i - 1][j - (o)], dp[i][j]);         }         dp[i][j] = min(dp[i][j], dp[i - 1][j]);       }     }     cout << dp[n][n] << endl;   }   