#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n;
	long *a;
	long sum = 0;
	scanf("%d", &n);
	a = (long *)malloc(sizeof(long) * n);
	for(int i=0; i<n; i++){
		scanf("%ld", &a[i]);
	}
	for(int j=0; j<n-1; j++){
		for(int k=j+1; k<n; k++){
			if(k-j == a[j] + a[k]){
				sum++;
			}
		}
	}
	printf("%ld\n", sum);
	return 0;
}