local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end
N=io.read"*n"
A=reada(N)

local function count(t)
	local ret=0
	for _,_ in pairs(t)do ret=ret+1 end
	return ret
end

lt={}rt={}
for i=1,N do
	local l=i-A[i]
	if(lt[l]==nil)then lt[l]={}end
	table.insert(lt[l],i)
	
	local r=i+A[i]
	if(rt[r]==nil)then rt[r]={}end
	table.insert(rt[r],i)
end

s=0
for k,v in pairs(rt)do
	if(lt[k])then
		s=s+count(v)*count(lt[k])
	end
end
print(s)
