#include <bits/stdc++.h>
int main() {
  size_t N;
  std::cin >> N;
  std::vector<long> A(N);
  for (size_t i = 0; i < N; i++) {
    long a;
    std::cin >> a;
    if (i == 0)
      A[0] = a;
    else
      A[i] = A[i - 1] + a;
  }
  std::sort(A.begin(), A.end());
  size_t ans = 0;
  size_t cnt_same = 0;
  long prev = 0;
  for (auto const a : A) {
    if (prev == a) {
      cnt_same++;
      ans += cnt_same;
    } else {
      cnt_same = 0;
    }
    prev = a;
  }
  std::cout << ans << std::endl;
  return 0;
}
