#include <bits/stdc++.h>
int N;
std::map<int64_t, int> m;
int main() {
  scanf("%d", &N);
  int64_t s = 0;
  m.insert(std::make_pair(0, 1));
  int64_t sum = 0;
  for (int i = 0; i < N; i++) {
    int tmp;
    scanf(" %d", &tmp);
    sum += tmp;
    auto it = m.find(sum);
    if (it == m.end()) {
      m.insert(std::make_pair(sum, 1));
    } else {
      it->second++;
    }
  }
  int64_t count = 0;
  for (auto& kv : m) {
    count += (kv.second * (kv.second - 1)) / 2;
  }
  printf("%lld\n", count);
  return 0;
}
