#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e3 + 10, inf = 1e17;
long long dp[2][4005];
int t[maxn], c[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> t[i] >> c[i];
  for (int i = 1; i <= n; i++) {
    bool cur = i % 2, cur_ = 1 - cur;
    for (int l = -n; l <= n; l++) {
      if (i == 1) {
        if (l < -t[i])
          dp[cur][l + n] = inf;
        else if (l < 1)
          dp[cur][l + n] = c[i];
        else
          dp[cur][l + n] = 0;
      } else if (l < i) {
        int m = min(n, l + t[i]);
        dp[cur][l + n] = dp[cur_][m + n] + c[i];
        if (l + n > 0)
          dp[cur][l + n] = min(dp[cur][l + n], dp[cur_][l + n - 1]);
      }
    }
  }
  cout << dp[n % 2][n];
}
