#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 10;
int n, m, w[maxn];
long long int c[maxn], f[maxn * maxn], maxa, sum, edg;
int Read() {
  int po = 1, num = 0;
  char gc = getchar();
  while (gc < '0' || gc > '9') {
    if (gc == '-') po *= -1;
    gc = getchar();
  }
  while ('0' <= gc && gc <= '9') {
    num = num * 10 + gc - '0';
    gc = getchar();
  }
  return num * po;
}
long long int read() {
  long long int po = 1, num = 0;
  char gc = getchar();
  while (gc < '0' || gc > '9') {
    if (gc == '-') po *= -1;
    gc = getchar();
  }
  while ('0' <= gc && gc <= '9') {
    num = num * 10 + gc - '0';
    gc = getchar();
  }
  return num * po;
}
long long int write(long long int number) {
  if (number / 10 > 0) write(number / 10);
  int now = (int)(number % 10);
  putchar(now + '0');
}
inline long long int Min(long long int X, long long int Y) {
  return (X < Y) ? X : Y;
}
inline long long int Max(long long int X, long long int Y) {
  return (X > Y) ? X : Y;
}
int main() {
  sum = edg = m = 0;
  maxa = -1;
  n = Read();
  for (int i = 1; i <= n; ++i) {
    w[i] = Read(), c[i] = read();
    ++w[i];
    if (w[i] > m) m = w[i];
    sum += c[i];
  }
  m += n;
  memset(f, 0x7f, sizeof(f));
  f[0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = m - w[i]; j >= 0; --j) {
      if (f[j + w[i]] > f[j] + c[i]) f[j + w[i]] = f[j] + c[i];
      if (j + w[i] >= n) maxa = Min(maxa, f[j + w[i]]);
      if (maxa == -1) maxa = f[j + w[i]];
    }
  printf("%lld\n", maxa);
}
