#include<stdio.h>

int N;
int H[200100];

int answer = 0;

int main(void){

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

    printf("%d\n", answer);

    return 0;
}