#include<stdio.h>
int main () {
	int count = 0;
	int studentNumber;
	scanf("%d", &studentNumber); 
	int hightArray[200000];
	int i = 0, j = 0;
	for(i = 0; i < studentNumber; i++) {
		scanf("%d", &hightArray[i]);
	}
	
	int limit = studentNumber - 1;
	int temp;
	for(i = 0; i < limit; i++) {
		temp = hightArray[i];
		if(temp >= studentNumber - i - 1) {
			break;
		} else {
			for(j = i + temp + 1; j < studentNumber; j++) {
				int hight = hightArray[j];
				if (hight + temp == j - i) {
					count ++;
				}
			}
		}
	}
	
	printf("%d", count);
}