local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local ret = 0
local right = {}
for i = n, 1, -1 do
  local tgt = -a[i] - i
  if right[tgt] then
    ret = ret + right[tgt]
  end
  local add = a[i] - i
  if not right[add] then
    right[add] = 1
  else
    right[add] = right[add] + 1
  end
end
local left = {}
for i = 1, n do
  local tgt = i - a[i]
  if left[tgt] then
    ret = ret + left[tgt]
  end
  local add = a[i] + i
  if not left[add] then
    left[add] = 1
  else
    left[add] = left[add] + 1
  end
end
print(math.floor(ret / 2))
