Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim s(n) As Long

        For i As Integer = 0 To n - 1
            Dim a As Integer = NextInt()
            s(i + 1) = s(i) + a
        Next

        Array.Sort(s)
        Dim ans, cnt As Long
        For i As Integer = 0 To s.Length - 2
            If s(i) = s(i + 1) Then
                cnt += 1
            Else
                cnt = 0
            End If
            ans += cnt
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module
