#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <cstdlib>

using namespace std;



int main() {
  int n;
  scanf("%d", &n);
  long a[200000];
  for(int i=0; i<n; ++i) {
    scanf("%ld", &(a[i]));
  }

  unordered_map<long, long> part_sums;
  part_sums[0] = 1;
  long sum = 0;
  long count = 0;
  for(int i=0; i<n; ++i) {
    sum += a[i];
    for(auto& pair : part_sums) {
      if(pair.second == sum) count += plus;
    }
    auto it = part_sums.find(sum);
    if(it == part_sums.end()) {
      part_sums[sum] = 1;
    } else {
      ((*it).second)++;
    }
  }
  printf("%ld\n", count);
}
