#include <bits/stdc++.h>
int main() {
  int N;
  std::cin >> N;
  std::vector<int> S(N + 1);
  S[0] = 0;
  int A;
  for (int i = 0; i < N; ++i) {
    std::cin >> A;
    S[i + 1] = S[i] + A;
  }
  std::sort(S.begin(), S.end());
  int count = 0;
  int same = 1;
  for (int i = 0; i < N; ++i) {
    if (S[i] == S[i + 1])
      ++same;
    else {
      count += same * (same - 1) / 2;
      same = 1;
    }
  }
  count += same * (same - 1) / 2;
  std::cout << count << std::endl;
  return 0;
}
