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

max_length = 10e5

def func(A):
    count = 0
    for i in range(len(A)):
        s = sum(A[:i+1])
        if s == 0:
            count += 1
    return count


def main():
    N = int(input())
    A = input().split()
    A = [int(a) for a in A]
    count = 0
    for i in range(N):
        count += func(A[i:])
    print(count, end='')


if __name__ == '__main__':
    main()
