n=io.read("*n","*l")
m={}
combination=0
for i=1,n do
    a=io.read("*n")
    if not m[i+a] then
        m[i+a]=0
    end
    if m[i-a] then
        combination=combination+m[i-a]
    end
    m[i+a]=m[i+a]+1
end
print(combination)