Class Main
    Public Shared Sub Main()
    Dim N As long = Console.ReadLine()
    Dim str() As string = Split(Console.ReadLine())
    dim A(N) as long
    dim S as integer = 0
    dim i1,i2 as integer
    for i2 = 0 to N - 1
    	A(i2) = clng(str(i2))
	next i2
    for i1 = 0 to N - 2
 	    for i2 = i1 + 2 to N - 1
		  	if i2 - i1 = A(i1) + A(i2) then
    			S += 1
  			end if
		next i2
  	next i1
      Console.WriteLine(S)
   End Sub
End Class
