Module AtCoder166
  
    Sub Main(args As String())

        Dim memberCount As Integer = CInt(Console.ReadLine())
        Dim member_height_List As List(Of Integer) = New List(Of Integer)()
        Dim arr As String() = Split(Console.ReadLine())
        For i As Integer = 1 To memberCount
            '身長代入
            member_height_List.Add(CInt(arr(i - 1)))
        Next

        Dim ret As Integer = 0
        For j As Integer = 1 To memberCount
            For k As Integer = 1 To memberCount
                If j <= k Then Continue For
                Dim sa As Integer = Math.Abs(j - k)
                Dim wa As Integer = member_height_List(j - 1) + member_height_List(k - 1)
                If sa = wa Then ret = ret + 1
            Next
        Next

        Console.WriteLine(ret.ToString())

    End Sub

End Module