#include <stdio.h>

int main(void)
{
    int N, A[200001];    
    int i, j, counter = 0;

    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    
    for(i = 0; i < N-1; i++){
        for(j = i + A[i] + 1; j < N; j++){
            if(j-i == A[i]+A[j]){
                counter++;
            }
        }
    }

    printf("%d", counter);

    return 0;
}