#include <bits/stdc++.h>
using namespace std;
long long int dp[2001][6001];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i <= 2000; ++i)
    for (int j = 0; j <= 6000; ++j) dp[i][j] = 100000000000000;
  pair<long long int, long long int> A[n + 1];
  for (int i = 1; i <= n; ++i) {
    int a, b;
    cin >> a >> b;
    A[i].first = a;
    A[i].second = b;
  }
  dp[0][2000] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 6000; ++j) {
      if (j > 0) dp[i][j - 1] = min(dp[i - 1][j], dp[i][j - 1]);
      if (j + A[i].first <= 6000)
        dp[i][j + A[i].first] =
            min(dp[i][j + A[i].first], dp[i - 1][j] + A[i].second);
    }
  }
  long long int ans = 100000000000000;
  for (int i = 2000; i <= 6000; ++i) ans = min(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}
