#include <stdio.h>

int main()
{

    int n;
    scanf("%d", &n);

    long a[200000];
    long y[200000];
    long o[200000];


    for (int i = 0; i < n; i++)
    {
        scanf("%ld", &a[i]);
        y[i]=a[i]+i+1;
        o[i] = i + 1 - a[i];
    }

    long pare[200001];
    for (int i = 0; i < 200001; i++)
    {
        pare[i] = 0;
    }

    long count = 0;
    for (int i = 0; i < n; i++)
    {
        if(o[i]>0){
        count = pare[o[i]] + count;
        //printf("%ld %d-\n", o[i],count);
        }
        if(y[i]<200001){
        pare[y[i]]++;
        }
//printf("%ld  %d----\n", y[i], pare[y[i]]);
        }

        printf("%ld",count);
   

    printf("\n");
}