#include <bits/stdc++.h>
using std::abs;
using std::array;
using std::cerr;
using std::cin;
using std::cout;
using std::generate;
using std::make_pair;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::unique;
using std::vector;
template <typename T>
T input() {
  T res;
  cin >> res;
  {};
  return res;
}
template <typename IT>
void input_seq(IT b, IT e) {
  std::generate(b, e,
                input<typename std::remove_reference<decltype(*b)>::type>);
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n = input<int>();
  vector<int64_t> psums(n + 1);
  for (int i = 1; i <= n; ++i) psums[i] = psums[i - 1] + input<int>();
  std::map<int64_t, int> cnt;
  for (int i = 0; i <= n; ++i) cnt[psums[i]] += 1;
  int64_t ans = 0;
  for (auto elem : cnt) ans += elem.second * (elem.second - 1);
  cout << ans / 2 << "\n";
  return 0;
}
