#include <bits/stdc++.h>
using namespace std;
using LLI = long long int;
int main(void) {
  int N, a, res = 0, sum = 0;
  vector<int> vec;
  vector<int> vec2;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    vec.push_back(a);
  }
  sum = vec[0];
  vec2.push_back(sum);
  for (int i = 1; i < N; i++) {
    sum = sum + vec[i];
    vec2.push_back(sum);
  }
  for (int i = 0; i < N; i++) {
    if (vec2[i] == 0) {
      res++;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      sum = vec2[j] - vec2[i];
      if (sum == 0 && i != j) {
        res++;
      }
    }
  }
  cout << res << endl;
}
