import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val a = IntArray(n){scn.nextInt()}
	var cnt = 0L
	val s = a.mapIndexed{i,v -> i-v}.sorted()
	val p = a.mapIndexed{i,v -> i+v}.sorted()
	var si = 0
	var pi = 0
	while(si<n && pi<n){
		if (s[si]<p[pi]) si++
		else if (s[si]>p[pi]) pi++
		else {
			var tsi = si
			var tpi = pi
			while(tsi<n && s[tsi]==s[si]) tsi++
			while(tpi<n && p[tpi]==p[pi]) tpi++
			cnt += (tsi-si).toLong()*(tpi-pi)
			si = tsi
			pi = tpi
		}
	}
	println(cnt)
}