program sample
implicit none

integer :: n
integer, allocatable :: a(:), p(:), q(:)

integer :: i, j
integer :: number


read(*,*) n
allocate(a(n))
read(*,*) a
allocate(q(n))

number = 0

do i = 1, n
q(i) = i - a(i)
a(i) = a(i) + i
end do

do i = 1, n-1
do j = i+1, n
if (a(i) == q(j)) then
number = number + 1
end if
end do
end do


write(*,*) number

stop
end program sample