# -*- coding: utf-8 -*-



# AtCoder Grand Contest

# Problem A





if __name__ == '__main__':

    from collections import Counter



    n = int(eval(input()))

    a = [0] + list(map(int, input().split()))

    s = [0] * len(a)



    for i in range(1, n + 1):

        s[i] += s[i - 1] + a[i]



    print((sum([si * (si - 1) // 2 for si in list(Counter(s).values())])))

# -*- coding: utf-8 -*-



# AtCoder Grand Contest

# Problem A





if __name__ == '__main__':

    from itertools import accumulate

    from collections import Counter



    n = int(eval(input()))

    a = [0] + list(map(int, input().split()))



    # See:

    # https://www.youtube.com/watch?v=8BHBFMrZ8VM

    # https://beta.atcoder.jp/contests/agc023/submissions/2431021

    s = list(accumulate(a))



    print((sum([si * (si - 1) // 2 for si in list(Counter(s).values())])))

# -*- coding: utf-8 -*-
# AtCoder Grand Contest
# Problem A
if __name__ == "__main__":
    from collections import Counter

    n = int(eval(input()))
    a = [0] + list(map(int, input().split()))
    s = [0] * len(a)
    for i in range(1, n + 1):
        s[i] += s[i - 1] + a[i]
    print((sum([si * (si - 1) // 2 for si in list(Counter(s).values())])))

# -*- coding: utf-8 -*-
# AtCoder Grand Contest
# Problem A
if __name__ == "__main__":
    from itertools import accumulate
    from collections import Counter

    n = int(eval(input()))
    a = [0] + list(map(int, input().split()))
    # See:
    # https://www.youtube.com/watch?v=8BHBFMrZ8VM
    # https://beta.atcoder.jp/contests/agc023/submissions/2431021
    s = list(accumulate(a))
    print((sum([si * (si - 1) // 2 for si in list(Counter(s).values())])))

+    from itertools import accumulate -    s = [0] * len(a) -    for i in range(1, n + 1): -        s[i] += s[i - 1] + a[i] +    # See: +    # https://www.youtube.com/watch?v=8BHBFMrZ8VM +    # https://beta.atcoder.jp/contests/agc023/submissions/2431021 +    s = list(accumulate(a))