#include <stdio.h>
#include <stdlib.h>
int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
int main(void){
    // Your code here!
    long long int N, i, j, a, tmp;
    scanf("%lld", &N);
    long long int A[2][N];
    for (i = 0; i < N; i++)
    {
        scanf("%lld", A[0] + i);
        A[1][i] = i - A[0][i];
        A[0][i] += i;
    }
    qsort(A[0], N, sizeof(long long int), cmpnum);
    qsort(A[1], N, sizeof(long long int), cmpnum);
    a = 0;
    j = 0;
    tmp = 0;
    
    
   
    
    for (i = 0; i < N; i++)
    {
        tmp = j;
        for (j = tmp; A[1][j] < A[0][i]; j++)
            ;
        for (j = j; A[1][j] == A[0][i]; j++)
            a++;
        j = tmp;
    }
    printf("%lld", a);
}



// j - i = Aj + Ai
// Ai + i = Aj - j


