#include <stdio.h>
#include <math.h>
#include <stdlib.h>
# define ll long long

int main()
{
    int n;
    scanf ("%d\n",&n);
    //printf ("%d",n);
    ll int arr[n+1];
    
    for (int i=1 ; i<n+1;i++)
    {
        scanf ("%lld ",&arr[i]);
    }
    scanf ("\n");
    
    ll int cnt =0;
    
    for (int i=1;i <= n-1;i++)
    {
        for (int j=i+1 ; j<=n;j++)
        {
           if ((ll int)arr[i] + (ll int)arr[j] == (ll int)(j-i)) cnt++; 
        }
    }
    printf ("%lld\n",cnt);
    return 0;
}