program ABC166E
    implicit none
    integer::n,i,j,ans
    real(8),allocatable::a(:)
    read*,n
    allocate(a(n))
    read*,a
    ans = 0
    do i = 1,n
        do j = i,n
            if (j - i == a(i) + a(j)) ans = ans + 1
        end do
    end do
    print*,ans
end program ABC166E