#include <bits/stdc++.h>
using namespace std;
struct _OMAZINAI_ {
  _OMAZINAI_() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
  }
} __omazinai_instance__;
void _INPUT_IMPL_(){};
template <class T, class... Args>
void _INPUT_IMPL_(T& dest, Args&... args) {
  cin >> dest;
  _INPUT_IMPL_(args...);
}
void _OUTPUT_IMPL_(){};
template <class T, class... Args>
void _OUTPUT_IMPL_(T dest, Args... args) {
  cout << dest << (sizeof...(Args) ? " " : "");
  _OUTPUT_IMPL_(args...);
}
long long int vec[300000] = {}, sum[300000] = {}, tmp = 0, cnt = 0;
int main() {
  int N;
  _INPUT_IMPL_(N);
  for (long long int(i) = 0; (i) < (N); ++(i)) {
    cin >> vec[i];
    sum[i] = tmp;
    tmp += vec[i];
  }
  sum[N] = tmp;
  sort(sum, sum + N + 1);
  auto add = [&](int n) { cnt += n * (n - 1) / 2; };
  tmp = 1;
  for (long long int(i) = 0; (i) < (N + 1); ++(i)) {
    if (sum[i + 1] == sum[i])
      ++tmp;
    else {
      add(tmp);
      tmp = 1;
    }
  }
  (_OUTPUT_IMPL_(cnt), std::cout << std::endl);
}
