#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  std::cin >> n;
  int a[n];
  int sum = 0;
  std::unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    sum += a[i];
    mp[sum]++;
  }
  int count = 0;
  int x;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    x = itr->second;
    if (itr->first == 0) {
      count += (x * (x + 1) / 2);
    } else {
      count += (x * (x - 1) / 2);
    }
  }
  std::cout << count << std::endl;
}
