#include <stdio.h>
int main()
{
  int N;
  int A[200000];
  int i;
  int j;
  int temp;
  int counter = 0;
  scanf("%d", &N);
  for(i = 0; i < N; ++i)
    scanf("%d", &A[i]);
  
  for(i = 0; i < N; ++i){
    for(j = i; j < N; ++j){
      temp = (i+1) - (j+1);
      if(temp < 0)
        temp *= -1;
      
      if((A[i] + A[j]) == temp)
        ++counter;
    }
  }
  printf("%d\n", counter);
  return 0;
}