program sample
implicit none

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

integer :: i, j
integer :: number

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

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

write(*,*) number

stop
end program sample