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

int main()
{
    int N;
    std::vector<int> A;
    
    std::cin >> N;
    
    int a;
    while(std::cin >> a)
        A.push_back(a);
    
    int c = 0;

    for(auto it = std::cbegin(A); it != std::cend(A); it++) {
        if(*it == 0){
            c++;
            continue;
        } else {
          for(int size = 2; size <= std::distance(it, std::cend(A)); size++) {
              if(!std::accumulate(it, it + size, 0))
                  c++;
          }
        }
    }       
    
    std::cout << c << std::endl;
}