#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
long long dp[N], minn = 1e18 + 10;
long long n;
long long sum[N];
long long ans = 0;
long long w[N];
long long c[N];
long long m;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> c[i];
    w[i]++;
    m = max(m, w[i]);
  }
  m += n;
  for (int i = 1; i <= m; i++) {
    dp[i] = 1e18 + 10;
  }
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = m; j >= w[i]; j--) {
      dp[j] = min(dp[j], dp[j - w[i]] + c[i]);
      if (j >= n) minn = min(minn, dp[j]);
    }
  }
  cout << minn << endl;
  return 0;
}
