import numpy as np

import math

import collections

import fractions

import itertools



def solve():

    n = int(eval(input()))

    a = list(map(int, input().split()))

    ruiseki = [0]

    ans = 0

    for i in range(n):

        ruiseki.append(ruiseki[i]+a[i])

    c = list(collections.Counter(ruiseki).values())

    for i in c:

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

    print(ans)

    return 0



if __name__ == "__main__":

    solve()

#fooooooooooooooo!! yattaze!! AC!!
import math

import collections

import fractions

import itertools



def solve():

    n = int(eval(input()))

    a = list(map(int, input().split()))

    ruiseki = [0]

    ans = 0

    for i in range(n):

        ruiseki.append(ruiseki[i]+a[i])

    c = collections.Counter(ruiseki)

    for i in c:

        ans += (c[i]*(c[i]-1)//2)

    print(ans)

    return 0



if __name__ == '__main__':

    solve()
import numpy as np
import math
import collections
import fractions
import itertools


def solve():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ruiseki = [0]
    ans = 0
    for i in range(n):
        ruiseki.append(ruiseki[i] + a[i])
    c = list(collections.Counter(ruiseki).values())
    for i in c:
        ans += i * (i - 1) // 2
    print(ans)
    return 0


if __name__ == "__main__":
    solve()
# fooooooooooooooo!! yattaze!! AC!!

import math
import collections
import fractions
import itertools


def solve():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ruiseki = [0]
    ans = 0
    for i in range(n):
        ruiseki.append(ruiseki[i] + a[i])
    c = collections.Counter(ruiseki)
    for i in c:
        ans += c[i] * (c[i] - 1) // 2
    print(ans)
    return 0


if __name__ == "__main__":
    solve()

-import numpy as np -    c = list(collections.Counter(ruiseki).values()) +    c = collections.Counter(ruiseki) -        ans += i * (i - 1) // 2 +        ans += c[i] * (c[i] - 1) // 2 -# fooooooooooooooo!! yattaze!! AC!!