from collections import defaultdict



def main():

    n = int(eval(input()))

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



    r = [0]

    d = defaultdict(int)

    d[0] = 1

    ans = 0

    for i in range(n):

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

        ans += d[r[i+1]]

        d[r[i+1]] += 1

    print(ans)





if __name__ == '__main__':

    main()
from fractions import gcd

from datetime import date, timedelta

from heapq import*

import math

from collections import defaultdict, Counter, deque

import sys

from bisect import *

import itertools

import copy

sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7





def main():

    n = int(eval(input()))

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

    

    ans = 0

    ruiseki = [0]

    d = defaultdict(int)

    d[0] = 1

    for i in range(n):

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

        ans += d[ruiseki[i+1]]

        d[ruiseki[i + 1]] += 1

    print(ans)



if __name__ == '__main__':

    main()

from collections import defaultdict


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    r = [0]
    d = defaultdict(int)
    d[0] = 1
    ans = 0
    for i in range(n):
        r.append(r[i] + a[i])
        ans += d[r[i + 1]]
        d[r[i + 1]] += 1
    print(ans)


if __name__ == "__main__":
    main()

from fractions import gcd
from datetime import date, timedelta
from heapq import *
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy

sys.setrecursionlimit(10**7)
MOD = 10**9 + 7


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ans = 0
    ruiseki = [0]
    d = defaultdict(int)
    d[0] = 1
    for i in range(n):
        ruiseki.append(ruiseki[i] + a[i])
        ans += d[ruiseki[i + 1]]
        d[ruiseki[i + 1]] += 1
    print(ans)


if __name__ == "__main__":
    main()

-from collections import defaultdict +from fractions import gcd +from datetime import date, timedelta +from heapq import * +import math +from collections import defaultdict, Counter, deque +import sys +from bisect import * +import itertools +import copy + +sys.setrecursionlimit(10**7) +MOD = 10**9 + 7 -    r = [0] +    ans = 0 +    ruiseki = [0] -    ans = 0 -        r.append(r[i] + a[i]) -        ans += d[r[i + 1]] -        d[r[i + 1]] += 1 +        ruiseki.append(ruiseki[i] + a[i]) +        ans += d[ruiseki[i + 1]] +        d[ruiseki[i + 1]] += 1