#include <bits/stdc++.h>
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int N;
  std::cin >> N;
  std::vector<std::int64_t> input(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> input[i];
  }
  std::vector<std::int64_t> list(N + 1);
  int result = 0;
  for (std::int64_t start = 0; start < N; ++start) {
    std::int64_t sum = 0;
    for (std::int64_t i = start; i < N; ++i) {
      sum += input[i];
      if (sum == 0) {
        int n = list[start] + 1;
        list[i + 1] += n;
        result += n;
        break;
      }
    }
  }
  std::cout << result << std::endl;
  return 0;
}
