def main():

    N = int(eval(input()))

    A = [int(i) for i in input().split()]

    from itertools import accumulate

    S = accumulate([0] + A)

    from collections import Counter

    c = Counter(S)

    ans = 0

    for v in list(c.values()):

        if v > 1:

            ans += v*(v-1)//2

    print(ans)





if __name__ == '__main__':

    main()

def main():

    from itertools import accumulate

    from collections import Counter

    N = int(eval(input()))

    A = [int(i) for i in input().split()]

    S = list(accumulate([0] + A))

    # print(S)

    c = Counter(S)

    ans = 0

    for v in list(c.values()):

        ans += v*(v-1)//2

    print(ans)





if __name__ == '__main__':

    main()

def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    from itertools import accumulate

    S = accumulate([0] + A)
    from collections import Counter

    c = Counter(S)
    ans = 0
    for v in list(c.values()):
        if v > 1:
            ans += v * (v - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

def main():
    from itertools import accumulate
    from collections import Counter

    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    S = list(accumulate([0] + A))
    # print(S)
    c = Counter(S)
    ans = 0
    for v in list(c.values()):
        ans += v * (v - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

+    from itertools import accumulate +    from collections import Counter + -    from itertools import accumulate - -    S = accumulate([0] + A) -    from collections import Counter - +    S = list(accumulate([0] + A)) +    # print(S) -        if v > 1: -            ans += v * (v - 1) // 2 +        ans += v * (v - 1) // 2