#include <bits/stdc++.h>
bool next(const std::string& s, std::vector<char>& vocab, std::string& result) {
  if (s.empty()) {
    return false;
  }
  char back = s.back();
  auto s2 = s.substr(0, s.size() - 1);
  auto it = std::upper_bound(vocab.begin(), vocab.end(), back);
  if (it != vocab.end()) {
    result = s2 + *it;
    return true;
  } else {
    vocab.insert(it, back);
    return next(s2, vocab, result);
  }
}
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int N;
  std::cin >> N;
  std::vector<int> input(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> input[i];
  }
  int result = 0;
  for (int start = 0; start < N; ++start) {
    int sum = 0;
    for (int i = start; i < N; ++i) {
      sum += input[i];
      if (sum == 0) {
        ++result;
      }
    }
  }
  std::cout << result << std::endl;
  return 0;
}
