#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> time(n);
  vector<int> price(n);
  for (int i = 0; i < n; i++) {
    cin >> time[i] >> price[i];
  }
  vector<vector<pair<long long, int> > > dp(
      n + 1, vector<pair<long long, int> >(n + 1, {1000000000000000, 0}));
  for (int i = 0; i <= n; i++) {
    dp[0][i].first = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j].first =
          min(dp[i][j - 1].first,
              dp[max(i - time[j - 1] - 1, 0)][j - 1].first + price[j - 1]);
      if (min(dp[i][j - 1].first, dp[max(i - time[j - 1] - 1, 0)][j - 1].first +
                                      price[j - 1]) == dp[i][j - 1].first) {
        dp[i][j].second = dp[i][j - 1].second;
      } else {
        dp[i][j].second = dp[max(i - time[j - 1] - 1, 0)][j - 1].second;
      }
    }
  }
  cout << dp[n][n].first - dp[n][n].second;
  return 0;
}
