#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;
    for(auto it = std::cbegin(A); it != std::cend(A); it++) {
        long csum = *it;
        for(auto sit = it + 1; sit != std::cend(A); sit++) {
            csum += *sit;
            if(csum == 0)
                c++;
        }
    }
    
    std::cout << c << std::endl;
}