#include <stdio.h>

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