def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0]
    t = 0
    for i in a:
        t += i
        ls.append(t)
    import collections
    ls = collections.Counter(ls).most_common()
    cnt = 0
    for k, v in ls:
        if v > 1:
            tt = 1
            for i in range(1, v):
                tt *= i
            cnt += tt
    print(cnt)


if __name__ == '__main__':
    main()
