#include <bits/stdc++.h>
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;
  std::unordered_map<int, int> map;
  for (int start = 0; start < N; ++start) {
    int in = input[start];
    std::unordered_map<int, int> map2;
    for (auto& m : map) {
      map2[m.first + in] += m.second;
    }
    map = std::move(map2);
    map[in] = map[in] + 1;
    if (map.find(0) != map.end()) {
      result += map[0];
    }
  }
  std::cout << result << std::endl;
  return 0;
}
