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

int main(void) {
  long long int n;
  scanf("%lld", &n);
  long long int h[n];
  long long int count = 0;
  for (long long int i = 0; i < n; i++) {
    scanf(" %lld", &h[i]);
    if (h[i] < i) {
      for (long long int j = 0; j < i; j++) {
        long long int sum = h[i] + h[j];
        long long int diff = i - j;
        if (diff < 0) diff *= -1;
        if (diff == sum) count++; 
      }
    }
  }
  printf("%lld\n", count);
  return 0;
}
