#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];
  for (long long int i = 0; i < n; i++) {
    scanf(" %lld", &h[i]);
  }

  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i; j < n; j++) {
      long long int diff = j - i;
      if (diff >= 0) {
        if (diff == h[i] + h[j]) sum++;
      } else if (diff < 0) {
        diff *= -1;
        if (diff == h[i] + h[j]) sum++;
      }
    }
  }

  printf("%lld\n", sum);
  return 0;
}
