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

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n],sum[n],dif[n],pair_count[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    sum[i] = i+1+a[i];
    dif[i] = i+1-a[i];
    pair_count[i] = 0;
  }
  qsort(sum, n, sizeof(long), cmpnum);
  qsort(dif, n, sizeof(long), cmpnum);
  long cur = 0;
  long pairs = 0;
  for (long i = 0; i < n; i++) {
    if (i != 0 && sum[i] == sum[i-1]) {
      pair_count[i] = pair_count[i-1];
    } else {
      while (cur < n-1 && dif[cur] < sum[i]) {
        cur++;
      }
      if (dif[cur] > sum[i]) {
        continue;
      }
      while (dif[cur] == sum[i]) {
        pair_count[i]++;
        if (cur < n-1) {
          cur++;
        } else {
          break;
        }
      }
    }
  }
  for (long i = 0; i < n; i++) {
    pairs += pair_count[i];
  }
  printf("%ld\n", pairs);

  return 0;
}