#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<long long> v(n + 1);
  for (size_t i = 1; i <= n; i++) {
    std::cin >> v[i];
    v[i] += v[i - 1];
  }
  std::sort(v.begin(), v.end());
  int count = 0;
  std::map<long long, long long> m;
  for (size_t i = 0; i < n + 1; i++) {
    m[v[i]]++;
  }
  for (auto&& i : m) {
    count += (i.second * (i.second - 1)) / 2;
  }
  std::cout << count << std::endl;
  return 0;
}
