Module AtCoder166
  
    Sub Main(args As String())

        Dim memberCount As Integer = CInt(Console.ReadLine())
        Dim heightArr As Integer() = Split(Console.ReadLine()).Select(Of Integer)(Function(s) CInt(s)).ToArray()
        Dim mark(memberCount) As Long

        Dim ret As Integer = 0
        For i As Integer = 0 To memberCount - 1
            If 0 <= i - heightArr(i) Then ret += mark(i - heightArr(i))
            If i + heightArr(i) < memberCount Then mark(i + heightArr(i)) = mark(i + heightArr(i)) + 1
        Next

        Console.WriteLine(ret.ToString())

    End Sub


End Module