#include <iostream>
#include <vector>
#include <numeric>

int main()
{
    int N;
    std::vector<int> A;

    std::cin >> N;

    A.resize(N);
    for(auto&& An : A)
        std::cin >> An;

    unsigned c = 0;
    auto const last = std::cend(A);
    for(int i = 0; i < N; i++) {
    /* for(auto it = std::cbegin(A); it != last; it++) { */
        /* long csum = *it; */
        long csum = A[i];
        /* for(auto sit = it + 1; sit != last; sit++) { */
            /* csum += *sit; */
        for(int j = i + 1; j < N; j++) {
            csum += A[j];
            if(csum == 0)
                c++;
        }
    }

    std::cout << c << std::endl;
}
