#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::vector<ll> v(n);
  std::vector<ll> memo(n);
  std::cin >> v[0];
  memo[0] = v[0];
  for (size_t i = 1; i < n; i++) {
    std::cin >> v[i];
    memo[i] = memo[i - 1] + v[i];
  }
  std::vector<ll> memoFull(n);
  int count = 0;
  int sum = 0;
  for (size_t i = 0; i < n; i++) {
    sum += v[i];
    memo[i] = sum;
    if (sum == 0) {
      count++;
    }
  }
  for (size_t i = 1; i < n; i++) {
    for (size_t j = i; j < n; j++) {
      if (memoFull[i] - memo[j] == 0) {
        count++;
      }
    }
  }
  std::cout << count << '\n';
  return 0;
}
