#include <bits/stdc++.h>
using namespace std;
const long long INF = 100000000000000LL;
const int MAXN = 2002;
long long myCost[MAXN];
long long dp[MAXN][MAXN][2];
int main() {
  int n;
  cin >> n;
  int N = n;
  vector<pair<long long, long long> > items;
  for (int i = 0; i < n; i++) {
    long long t, c;
    cin >> t >> c;
    items.push_back(pair<long long, long long>(t, -c));
  }
  sort(items.begin(), items.end(), greater<pair<long long, long long> >());
  for (int i = 0; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++) dp[i][j][0] = dp[i][j][1] = INF;
  dp[0][1][1] = 0;
  dp[0][items[0].first][0] = (items[0].second) * (-1);
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j <= 2000; j++) {
      int next = i + 1;
      long long nt = items[next].first;
      long long co = (items[next].second) * -1;
      if (dp[i][j][0] < INF) {
        if (j > 0) {
          dp[next][j - 1][0] = min(dp[next][j - 1][0], dp[i][j][0]);
          if (j - 1 == 0) dp[next][0][1] = min(dp[next][0][1], dp[i][j][0]);
        }
        if (j == 0) dp[next][1][1] = min(dp[next][1][1], dp[i][j][0]);
        if (j + nt <= 2000) {
          dp[next][j + nt][0] = min(dp[next][j + nt][0], dp[i][j][0] + co);
        }
      }
      if (dp[i][j][1] < INF) {
        if (nt >= j) {
          dp[next][nt - j][0] = min(dp[next][nt - j][0], dp[i][j][1] + co);
          if (nt - j == 0)
            dp[next][0][1] = min(dp[next][0][1], dp[i][j][1] + co);
        }
        if (nt < j)
          dp[next][j - nt][1] = min(dp[next][j - nt][1], dp[i][j][1] + co);
        if (j + 1 <= 2000)
          dp[next][j + 1][1] = min(dp[next][j + 1][1], dp[i][j][1]);
      }
    }
  }
  long long ret = INF;
  for (int j = 0; j <= 2000; j++) ret = min(ret, dp[N - 1][j][0]);
  ret = min(ret, dp[N - 1][0][1]);
  cout << ret << endl;
  return 0;
}
