#include<stdio.h>
//ABC166E;ペア探索問題
int main(){
	int num, height[200001] = {};  
	long long int ans = 0;

	scanf("%d", &num);
	for(int member_i = 1; member_i <= num; member_i++){
		int h_temp;
		scanf("%d", &h_temp);

		//Lend_iとRend_jが等しい(i, j)が求めるペア
		int Lend_i = member_i - h_temp;
		int Rend_i = member_i + h_temp;

		//[Rend_i=Lend_j -> i<j]に注意
		if(Lend_i > 0)
			ans += height[Lend_i];
		if(Rend_i < num)
			height[Rend_i]++;
	}

	printf("%lld", ans);
	return 0;
}