#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  int A[n+1];
  int data[n+1];
  for(int i = 1;i <= n;i++) {
    scanf("%d", A + i);
    data[i] = 0;
  }
  int ret = 0;
  for(int i = 1;i <= n;i++) {
    if(i + A[i] < n)data[i + A[i]]++;
  }
  for(int i = 1;i <= n;i++) {
    if(i - A[i] > 0) ret += data[i - A[i]];
  }

  printf("%d\n", ret);
  return 0;
}