local N = io.read("*n")
local A = {}
for i = 1, N do
	A[i] = io.read("*n")
end

local count = 0
for i = 1, N - 1 do
	for j = i + 1, N do
		if j - i == A[i] + A[j] then
			count = count + 1
		end
	end
end

print(count)