def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0

    s = [0 for _ in range(N)]
    for i in range(N):
        if i == 0:
            s[i] = A[i]
        else:
            s[i] = s[i-1] + A[i]
    count += s.count(0)

    for i in range(N-1):
        del s[0]
        for j in range(len(s)):
            s[j] -= A[i]
        count += s.count(0)

    return count

if __name__ == '__main__':
    print(main())
