#include <bits/stdc++.h>
int main() {
  int a, n, i, cur, addBy = 0, prev = std::numeric_limits<int>::max(),
                    subSequences = 0;
  std::cin >> n;
  std::vector<int> sums(n + 1);
  sums[0] = 0;
  for (i = 0; i < n; i++) {
    std::cin >> a;
    sums[i + 1] = sums[i] + a;
  }
  std::sort(sums.begin(), sums.end());
  for (i = 0; i <= n; i++) {
    cur = sums[i];
    if (cur != prev) {
      prev = cur;
      addBy = 0;
    } else {
      addBy++;
      subSequences += addBy;
    }
  }
  std::cout << subSequences << std::endl;
  return 0;
}
