#include <bits/stdc++.h>
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.first == sum) count += pair.second;
    }
    auto it = part_sums.find(sum);
    if (it == part_sums.end()) {
      part_sums[sum] = 1;
    } else {
      ((*it).second)++;
    }
  }
  printf("%ld\n", count);
}
