#include <bits/stdc++.h>
using ll = long long;
int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) std::cin >> A[i];
  std::vector<int> cumsum(N + 1);
  for (int i = 0; i < N; i++) {
    cumsum[i + 1] = cumsum[i] + A[i];
  }
  std::unordered_map<int, int> counter;
  for (auto&& v : cumsum) {
    counter[v]++;
  }
  int res{0};
  for (auto&& p : counter) {
    int k{p.second};
    res += (k * (k - 1)) / 2;
  }
  std::cout << res << std::endl;
  return 0;
}
