#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,out=0;
    long a[200001]={0},num;
    scanf("%lu\n",&num);
    for(i=1;i<=num;i++){
        scanf("%lu",&a[i]);
    }
    for(i=num;i>=1;i--){
        if(a[i]>=i-1) out = out;
        else{
            for(j=1;j<=i-1;j++){
                if((i-j)==(a[i]+a[j])) out++;
            }
        }
    }
    printf("%d",out);
    return 0;
}
