/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>

int main()
{
    //printf("Hello World");
    int n;
    scanf("%d",&n);
    int a[n];
    int i=0,j=0;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int count=0;
    for(i=0;i<n-1;i++){
        for(j=i+a[i]+1;j<n;j++){
            if((j-i)==(a[i]+a[j])) ++count;
        }
    }
    printf("%d",count);
    return 0;
}
