import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    from itertools import accumulate

    B = [0] + A
    # 累積和を格納したリスト．A[l:r]の総和はB[r] - B[l]
    B = list(accumulate(B))
    BB = Counter(B)

    cnt = 0
    for k, v in BB.items():
        if v >= 2:
            cnt += (v*(v - 1) // 2)
    print(cnt)


resolve()