#include <bits/stdc++.h>
using namespace std;
long long dp[4005][2005], ar[2][2005], n;
long long f(long long t, long long i) {
  if (i == n + 1 && t < 0) return (1ll << 62);
  if (i == n + 1) return 0;
  if (t > 2000) t = 2000;
  if (dp[t + 2000][i] != -1) return dp[t + 2000][i];
  long long res = (1ll << 62);
  res = (res < f(t - 1, i + 1) ? res : f(t - 1, i + 1));
  res = (res < f(t + ar[0][i], i + 1) + ar[1][i]
             ? res
             : f(t + ar[0][i], i + 1) + ar[1][i]);
  return dp[t + 2000][i] = res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ar[0][i] >> ar[1][i];
  memset(dp, -1, sizeof dp);
  cout << f(0, 1);
  return 0;
}
