#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
inline void solve(), read();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read();
  solve();
  return 0;
}
long long n;
vector<long long> t, c, dp;
inline void solve() {
  for (long long i = 0; i < n; i++) {
    ++t[i];
  }
  dp.resize(n + 1, inf);
  dp[0] = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = n; j >= t[i]; j--) {
      (dp[j]) =
          ((dp[j]) > (dp[j - t[i]] + c[i])) ? (dp[j - t[i]] + c[i]) : (dp[j]);
    }
    for (long long j = t[i] - 1; j >= 0; j--) {
      (dp[j]) = ((dp[j]) > (c[i])) ? (c[i]) : (dp[j]);
    }
  }
  cout << dp[n] << "\n";
}
inline void read() {
  cin >> n;
  t.resize(n), c.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> t[i] >> c[i];
  }
}
