#include <iostream>
#include <map>

int main() {
  using i64 = long long;

  std::map<i64, i64> mp({{0, 1}});
  i64 ans = 0, acc = 0;
  while (n--) {
    i64 a;
    std::cin >> a;
    ans += mp[acc += a]++;
  }
  std::cout << ans << std::endl;
  return 0;
}
