#include <cstdio>
#include <algorithm>
using std::sort;
using std::lower_bound;
using std::upper_bound;

const int MAXN=200003;
int a[MAXN],L[MAXN],R[MAXN];

int main(void)
{
    int i,N;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",a+i);
        L[i] = i+1+a[i];
        R[i] = (i+1)-a[i];
    }
    sort(R,R+N);
    int ret = 0,lwbd,upbd;
    for(i=0;i<N;i++)
    {
        lwbd = lower_bound(R,R+N,L[i]) - &R[0];
        upbd = upper_bound(R,R+N,L[i]) - &R[0];
        
        ret+=upbd-lwbd;

    }
    printf("%d\n",ret);
    return 0;
}

