#include <bits/stdc++.h>
int main(void) {
  int n, a, t = 0, ans = 0;
  std::vector<int> s{0};
  std::cin >> n;
  for (int i = 0; i != n; i++) {
    std::cin >> a;
    s.push_back(s[i] + a);
  }
  std::sort(s.begin(), s.end());
  for (int i = 0; i <= n; i++) {
    if (i > 0 && s[i] == s[i - 1]) {
      t++;
      ans += t;
    } else
      t = 0;
  }
  std::cout << ans << std::endl;
  return 0;
}
