#include int min(int x, int y) { return (x < y) ? x : y; } int main(void) { int n, ring, i, prev, ans, p; while (scanf("%d", &n) == 1 && n) { prev = n+1; ans = 0; for (i = 0; i < n; i++) { scanf("%d", &ring); p = min(prev-1, ring); if (p <= 0) { ans++; } prev = p; } printf("%d\n", ans); } return 0; }