#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  long int n;
  long int a[100000000];
  long int count=0;
  scanf("%ld", &n);
  for(long int i=1;i<=n;i++){
    scanf("%ld", &a[i]);
  }
  for(long int i=1;i<=n;i++){
    for(long int j=i+1;j<=n;j++){
      if(labs(i-j) == a[i]+a[j]){
	count += 1;
      }
    }
  }
  printf("%ld\n", count);
  return 0;
}
