import collections



def main(N,A):

    B=[0]

    count = 0

    for i in range(N):

        T = A[i] + B[i]



        B.append(T)

    c = collections.Counter(B)



    for i in range(len(c)):

        k, v = c.popitem()

        for z in range(v):

            count += z



    return print(count)



if __name__ == "__main__":

    N=int(input())

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



    main(N,A)

def main(N,A):

    B=[0]

    count = 0

    for i in range(N):

        T = A[i] + B[i]











            #print('count:',count)

#





    # B = [A[i] +B[i] for i in range(N)]

    #

    # count = [ count + 1 for m in range(len(B)) if B[i] - B[i-m] == 0]



        # for m in range(len(B)):

        #     if T - B[m] == 0:

        #         # print(i, m)

        #         # print(B[i],B[i-m])

        #         # print(T)

        #         # print("kore",B[i],B[i-m])

        #         count += 1

        B.append(T)





    B = sorted(B)

    # print(B)

    c = 0

    for i in range(len(B)):

        if i==0:

            continue

        if B[i] == B[i-1]:

            c+=1

            count +=c

            # print(c)

            # 

            # print(count)

        else:

            c = 0



    #

    # c = collections.Counter(B)

    # for i in range(len(c)):

    #     k, v = c.popitem()

    #     for z in range(v):

    #         count += z





    #print(count)

    #print(B)

    return print(count)



if __name__ == "__main__":

    N=int(input())

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



    main(N,A)

import collections


def main(N, A):
    B = [0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]
        B.append(T)
    c = collections.Counter(B)
    for i in range(len(c)):
        k, v = c.popitem()
        for z in range(v):
            count += z
    return print(count)


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    main(N, A)

def main(N, A):
    B = [0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]
        # print('count:',count)
        #
        # B = [A[i] +B[i] for i in range(N)]
        #
        # count = [ count + 1 for m in range(len(B)) if B[i] - B[i-m] == 0]
        # for m in range(len(B)):
        #     if T - B[m] == 0:
        #         # print(i, m)
        #         # print(B[i],B[i-m])
        #         # print(T)
        #         # print("kore",B[i],B[i-m])
        #         count += 1
        B.append(T)
    B = sorted(B)
    # print(B)
    c = 0
    for i in range(len(B)):
        if i == 0:
            continue
        if B[i] == B[i - 1]:
            c += 1
            count += c
            # print(c)
            #
            # print(count)
        else:
            c = 0
    #
    # c = collections.Counter(B)
    # for i in range(len(c)):
    #     k, v = c.popitem()
    #     for z in range(v):
    #         count += z
    # print(count)
    # print(B)
    return print(count)


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    main(N, A)

-import collections - - +        # print('count:',count) +        # +        # B = [A[i] +B[i] for i in range(N)] +        # +        # count = [ count + 1 for m in range(len(B)) if B[i] - B[i-m] == 0] +        # for m in range(len(B)): +        #     if T - B[m] == 0: +        #         # print(i, m) +        #         # print(B[i],B[i-m]) +        #         # print(T) +        #         # print("kore",B[i],B[i-m]) +        #         count += 1 -    c = collections.Counter(B) -    for i in range(len(c)): -        k, v = c.popitem() -        for z in range(v): -            count += z +    B = sorted(B) +    # print(B) +    c = 0 +    for i in range(len(B)): +        if i == 0: +            continue +        if B[i] == B[i - 1]: +            c += 1 +            count += c +            # print(c) +            # +            # print(count) +        else: +            c = 0 +    # +    # c = collections.Counter(B) +    # for i in range(len(c)): +    #     k, v = c.popitem() +    #     for z in range(v): +    #         count += z +    # print(count) +    # print(B)