#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::unordered_map<int, int> mmap;
  std::vector<int> a(n, 0);
  for (int i = 0; i < n; ++i) {
    int x;
    std::cin >> x;
    a[i] = x;
    if (i != 0) a[i] += a[i - 1];
    if (mmap.find(a[i]) == mmap.end()) {
      mmap.insert(std::pair<int, int>(a[i], 1));
    } else {
      mmap[a[i]] += 1;
    }
  }
  long long count = 0;
  for (std::unordered_map<int, int>::iterator it = mmap.begin();
       it != mmap.end(); ++it) {
    int x = it->first;
    if (x == 0) {
      count += (it->second);
    }
    count += (mmap[x]) * (mmap[x] - 1) / 2;
  }
  std::cout << count << '\n';
}
