N = int(input())
A = list(map(int, input().split()))

def solve():
    ans = 0
    for i, A_i in enumerate(A[:-1]):
        sum_val = A_i
        for A_j in A[i+1:]:
            sum_val += A_j
            if sum_val == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    solve()