#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,b=0,c=1;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int a=A[0]-1;
    while(a>0&&c<N){
        b++; c++;
        if(A[b]>a){
            a=A[b];
        }
        a--;
    }
    cout<<c;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: