#include <bits/stdc++.h>
using namespace std;
void solve(long long N, std::vector<long long> A) {
  long long count = 0;
  vector<long long> tab(N);
  tab[0] = A[0];
  for (long long i = 1; i < N; i++) {
    tab[i] = tab[i - 1] + A[i];
  }
  for (long long i = 0; i < N; i++) {
    if (tab[i] == 0) count++;
    for (long long j = (i + 1); j < N; j++) {
      if ((tab[j] - tab[i]) == 0) count++;
    }
  }
  cout << count << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}
