#include <bits/stdc++.h>
using namespace std;
long long n, mem[2002][4005];
pair<long long, long long> ar[2005];
long long func(long long, long long);
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    ar[i].first = x;
    ar[i].second = y;
  }
  memset(mem, -1, sizeof(mem));
  cout << func(0, 2000);
}
long long func(long long idx, long long t) {
  if (t - 2000 >= n - idx) return 0;
  if (idx == n) {
    return 0x3f3f3f3f3f3f3f3f;
  }
  if (mem[idx][t] != -1) return mem[idx][t];
  return mem[idx][t] = min(func(idx + 1, t + ar[idx].first) + ar[idx].second,
                           func(idx + 1, t - 1));
}
